From eb4de256c86e1e85401183a190393e74512e03b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 5 Sep 2021 12:48:46 +0200 Subject: [PATCH] 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 7548f2f79d20031cd89ea7c2c83f6b3a9c2b1da4 Co-authored-by: Jay --- index.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 78f733f890..e5d6b66981 100644 --- a/index.d.ts +++ b/index.d.ts @@ -134,9 +134,8 @@ export interface AxiosInterceptorManager { eject(id: number): void; } -export interface AxiosInstance { - (config: AxiosRequestConfig): AxiosPromise; - (url: string, config?: AxiosRequestConfig): AxiosPromise; +export class Axios { + constructor(config?: AxiosRequestConfig); defaults: AxiosRequestConfig; interceptors: { request: AxiosInterceptorManager; @@ -153,10 +152,16 @@ export interface AxiosInstance { patch>(url: string, data?: any, config?: AxiosRequestConfig): Promise; } +export interface AxiosInstance extends Axios { + (config: AxiosRequestConfig): AxiosPromise; + (url: string, config?: AxiosRequestConfig): AxiosPromise; +} + export interface AxiosStatic extends AxiosInstance { create(config?: AxiosRequestConfig): AxiosInstance; Cancel: CancelStatic; CancelToken: CancelTokenStatic; + Axios: typeof Axios; isCancel(value: any): boolean; all(values: (T | Promise)[]): Promise; spread(callback: (...args: T[]) => R): (array: T[]) => R;