export interface 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 type Callback = (result: T) => void export interface Request extends Promise, AjaxRequestTask> {} export interface RequestConstructor extends PromiseConstructor { readonly prototype: Request new (executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Request task: AjaxRequestTask | null aborted: boolean onHeadersReceivedCallback: Callback | null offHeadersReceivedCallback: Callback | null onHeadersReceived(callback: Callback): void offHeadersReceived(callback: Callback): void } export interface AjaxRequestTask { abort(): T onHeadersReceived(callback: Callback): T offHeadersReceived(callback: Callback): T } export interface AjaxRequestConfig { 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 xhr?: (task: AjaxRequestTask, config: AjaxRequestConfig) => void validateStatus?: ((statusCode?: number) => boolean) | null adapter?: (config: AjaxRequestConfig, Request: RequestConstructor) => Promise } export type AjaxConfigType = | AjaxRequestConfig | (() => AjaxRequestConfig) | (() => Promise) | undefined export interface AjaxCallbackConfig extends AjaxRequestConfig { success?: Callback fail?: Callback complete?: Callback } 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 AjaxInvoke { >(config?: AjaxRequestConfig): Request >(config?: AjaxCallbackConfig): Request >(url?: string, data?: Data, config?: AjaxRequestConfig): Request } 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 } declare const Ajax: AjaxStatic export default Ajax