export type Method = 'get' | 'GET' | 'post' | 'POST' | 'put' | 'PUT' | 'delete' | 'DELETE' | 'options' | 'OPTIONS' | 'head' | 'HEAD' | 'patch' | 'PATCH'; export interface AxiosTransformer { (data: any, header?: any): any; } export interface AxiosBasicCredentials { username: string; password: string; } export interface AxiosRequestConfig { baseURL?: string; url?: string; method?: Method; data?: any; params?: any; headers?: any; responseType?: XMLHttpRequestResponseType; timeout?: number; transformRequest?: AxiosTransformer | AxiosTransformer[]; transformResponse?: AxiosTransformer | AxiosTransformer[]; cancelToken?: CancelToken; withCredentials?: boolean; xsrfCookieName?: string; xsrfHeaderName?: string; onDownloadProgress?: (e: ProgressEvent) => void; onUploadProgress?: (e: ProgressEvent) => void; auth?: AxiosBasicCredentials; validateStatus?: (status: number) => boolean; paramsSerializer?: (params: any) => string; } export interface AxiosResponse { data: T; status: number; statusText: string; headers: any; config: AxiosRequestConfig; request: XMLHttpRequest; } export interface AxiosPromise extends Promise> { } export interface AxiosError extends Error { config: AxiosRequestConfig; isAxiosError: boolean; code?: string; request?: any; response?: AxiosResponse; } export interface Axios { defaults: AxiosRequestConfig; interceptors: { request: InterceptorManager; response: InterceptorManager; }; request(config: AxiosRequestConfig): AxiosPromise; get(url: string, config?: AxiosRequestConfig): AxiosPromise; delete(url: string, config?: AxiosRequestConfig): AxiosPromise; head(url: string, config?: AxiosRequestConfig): AxiosPromise; options(url: string, config?: AxiosRequestConfig): AxiosPromise; post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; getUri(config?: AxiosRequestConfig): string; } export interface AxiosClassStatic { new (config: AxiosRequestConfig): Axios; } export interface AxiosInstance extends Axios { (config: AxiosRequestConfig): AxiosPromise; (url: string, config?: AxiosRequestConfig): AxiosPromise; } export interface AxiosStatic extends AxiosInstance { create(instanceConfig?: AxiosRequestConfig): AxiosInstance; CancelToken: CancelTokenStatic; Cancel: CancelStatic; isCancel: (value: any) => boolean; all(promises: Array>): Promise; spread(callback: (...args: T[]) => R): (arr: T[]) => R; Axios: AxiosClassStatic; } export interface InterceptorManager { use(resolved: ResolvedFn, rejected?: RejectedFn): number; eject(id: number): void; } export interface ResolvedFn { (val: T): T | Promise; } export interface RejectedFn { (error: any): any; } export interface CancelToken { promise: Promise; reason?: Cancel; throwIfRequested(): void; } export interface Canceler { (message?: string): void; } export interface CancelExecutor { (cancel: Canceler): void; } export interface CancelTokenSource { token: CancelToken; cancel: Canceler; } /** CancelToken 类接口 */ export interface CancelTokenStatic { new (executor: CancelExecutor): CancelToken; source(): CancelTokenSource; } export interface Cancel { message?: string; } export interface CancelStatic { new (message?: string): Cancel; }