export type AnyObject = { [x: string]: any } export type Data = string | AnyObject | ArrayBuffer export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'HEAD' | 'OPTIONS' | 'TRACE' export type DataType = 'json' | 'text' | 'html' export type ResponseType = 'text' | 'arraybuffer' export interface RequestTask { abort: () => void onHeadersReceived?: (listener: (header: any) => void) => void offHeadersReceived?: (listener: (header: any) => void) => void } export interface FetcherInstance { resolve: (value: T) => void reject: (reason?: any) => void source: () => Promise abort: () => Promise } export interface FetcherConstructor { new (): FetcherInstance } export interface CustomConfig {} export interface AjaxRequestConfig extends CustomConfig { baseURL?: string url?: string data?: Data query?: AnyObject params?: AnyObject header?: any method?: Method timeout?: number dataType?: DataType responseType?: ResponseType sslVerify?: boolean withCredentials?: boolean firstIpv4?: boolean fetcher?: FetcherInstance validateStatus?: ((statusCode?: number) => boolean) | null adapter?: (config: AjaxRequestConfig) => Promise } export type AjaxConfigType = | AjaxRequestConfig | (() => AjaxRequestConfig) | (() => Promise) | void export interface AjaxResponse { data: T statusCode: number header: any config: AjaxRequestConfig errMsg: string cookies: string[] } export interface AjaxInterceptorManager { use(onFulfilled?: (value: V) => T | Promise, onRejected?: (error: any) => any): number eject(id: number): void } export interface CustomResponse {} export type AjaxResult = keyof CustomResponse extends never ? AjaxResponse : CustomResponse export interface AjaxInvoke { >(config?: AjaxRequestConfig): Promise >(url?: string, data?: Data, config?: AjaxRequestConfig): Promise } export interface AjaxInstance extends AjaxInvoke { get: AjaxInvoke post: AjaxInvoke put: AjaxInvoke delete: AjaxInvoke connect: AjaxInvoke head: AjaxInvoke options: AjaxInvoke trace: AjaxInvoke getURL(config?: AjaxConfigType): Promise readonly defaults: AjaxRequestConfig readonly config: T interceptors: { request: AjaxInterceptorManager response: AjaxInterceptorManager } } export interface AjaxStatic extends AjaxInstance { create(config?: T): AjaxInstance Fetcher: FetcherConstructor } declare const Ajax: AjaxStatic declare const Fetcher: FetcherConstructor export { Fetcher } export default Ajax