mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
Exposing the Axios constructor in index.d.ts (#2872)
This patch allows TypeScript users to extend the `Axios` class without
the type checker complaining.
see 7548f2f79d
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Vendored
+8
-3
@@ -134,9 +134,8 @@ export interface AxiosInterceptorManager<V> {
|
|||||||
eject(id: number): void;
|
eject(id: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInstance {
|
export class Axios {
|
||||||
(config: AxiosRequestConfig): AxiosPromise;
|
constructor(config?: AxiosRequestConfig);
|
||||||
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
|
||||||
defaults: AxiosRequestConfig;
|
defaults: AxiosRequestConfig;
|
||||||
interceptors: {
|
interceptors: {
|
||||||
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
||||||
@@ -153,10 +152,16 @@ export interface AxiosInstance {
|
|||||||
patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AxiosInstance extends Axios {
|
||||||
|
(config: AxiosRequestConfig): AxiosPromise;
|
||||||
|
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AxiosStatic extends AxiosInstance {
|
export interface AxiosStatic extends AxiosInstance {
|
||||||
create(config?: AxiosRequestConfig): AxiosInstance;
|
create(config?: AxiosRequestConfig): AxiosInstance;
|
||||||
Cancel: CancelStatic;
|
Cancel: CancelStatic;
|
||||||
CancelToken: CancelTokenStatic;
|
CancelToken: CancelTokenStatic;
|
||||||
|
Axios: typeof Axios;
|
||||||
isCancel(value: any): boolean;
|
isCancel(value: any): boolean;
|
||||||
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
|
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
|
||||||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
||||||
|
|||||||
Reference in New Issue
Block a user