diff --git a/index.d.ts b/index.d.ts index 5cb94c5751..abc41588a4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ export type AxiosRequestHeaders = Record; export type AxiosResponseHeaders = Record & { - "set-cookie"?: string[] + 'set-cookie'?: string[]; }; export interface AxiosRequestTransformer { @@ -34,16 +34,26 @@ export interface AxiosProxyConfig { } export type Method = - | 'get' | 'GET' - | 'delete' | 'DELETE' - | 'head' | 'HEAD' - | 'options' | 'OPTIONS' - | 'post' | 'POST' - | 'put' | 'PUT' - | 'patch' | 'PATCH' - | 'purge' | 'PURGE' - | 'link' | 'LINK' - | 'unlink' | 'UNLINK'; + | 'get' + | 'GET' + | 'delete' + | 'DELETE' + | 'head' + | 'HEAD' + | 'options' + | 'OPTIONS' + | 'post' + | 'POST' + | 'put' + | 'PUT' + | 'patch' + | 'PATCH' + | 'purge' + | 'PURGE' + | 'link' + | 'LINK' + | 'unlink' + | 'UNLINK'; export type ResponseType = | 'arraybuffer' @@ -53,19 +63,31 @@ export type ResponseType = | 'text' | 'stream'; - export type responseEncoding = - | 'ascii' | 'ASCII' - | 'ansi' | 'ANSI' - | 'binary' | 'BINARY' - | 'base64' | 'BASE64' - | 'base64url' | 'BASE64URL' - | 'hex' | 'HEX' - | 'latin1' | 'LATIN1' - | 'ucs-2' | 'UCS-2' - | 'ucs2' | 'UCS2' - | 'utf-8' | 'UTF-8' - | 'utf8' | 'UTF8' - | 'utf16le' | 'UTF16LE'; +export type responseEncoding = + | 'ascii' + | 'ASCII' + | 'ansi' + | 'ANSI' + | 'binary' + | 'BINARY' + | 'base64' + | 'BASE64' + | 'base64url' + | 'BASE64URL' + | 'hex' + | 'HEX' + | 'latin1' + | 'LATIN1' + | 'ucs-2' + | 'UCS-2' + | 'ucs2' + | 'UCS2' + | 'utf-8' + | 'UTF-8' + | 'utf8' + | 'UTF8' + | 'utf16le' + | 'UTF16LE'; export interface TransitionalOptions { silentJSONParsing?: boolean; @@ -126,11 +148,12 @@ export interface HeadersDefaults { unlink?: AxiosRequestHeaders; } -export interface AxiosDefaults extends Omit, 'headers'> { +export interface AxiosDefaults + extends Omit, 'headers'> { headers: HeadersDefaults; } -export interface AxiosResponse { +export interface AxiosResponse { data: T; status: number; statusText: string; @@ -148,8 +171,7 @@ export interface AxiosError extends Error { toJSON: () => object; } -export interface AxiosPromise extends Promise> { -} +export interface AxiosPromise extends Promise> {} export interface CancelStatic { new (message?: string): Cancel; @@ -180,7 +202,10 @@ export interface CancelTokenSource { } export interface AxiosInterceptorManager { - use(onFulfilled?: (value: V) => T | Promise, onRejected?: (error: any) => any): number; + use( + onFulfilled?: (value: V) => T | Promise, + onRejected?: (error: any) => any + ): number; eject(id: number): void; } @@ -192,14 +217,40 @@ export class Axios { response: AxiosInterceptorManager; }; getUri(config?: AxiosRequestConfig): string; - request, D = any>(config: AxiosRequestConfig): Promise; - get, D = any>(url: string, config?: AxiosRequestConfig): Promise; - delete, D = any>(url: string, config?: AxiosRequestConfig): Promise; - head, D = any>(url: string, config?: AxiosRequestConfig): Promise; - options, D = any>(url: string, config?: AxiosRequestConfig): Promise; - post, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - put, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - patch, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; + request, D = any>( + config: AxiosRequestConfig + ): Promise; + get, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + delete, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + head, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + options, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + post, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + put, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + patch, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; } export interface AxiosInstance extends Axios { @@ -216,7 +267,7 @@ export interface AxiosStatic extends AxiosInstance { isCancel(value: any): boolean; all(values: Array>): Promise; spread(callback: (...args: T[]) => R): (array: T[]) => R; - isAxiosError(payload: any): payload is AxiosError; + isAxiosError(payload: any): payload is AxiosError; } declare const axios: AxiosStatic;