From 423f1ab669166ba124b44b06798eb1429510d5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 2 Apr 2020 19:38:49 +0200 Subject: [PATCH] Exposing the Axios constructor in index.d.ts This patch allows TypeScript users to extend the `Axios` class without the type checker complaining. see 7548f2f79d20031cd89ea7c2c83f6b3a9c2b1da4 --- index.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5ea0be90af..66a148863e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -127,9 +127,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; @@ -146,10 +145,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;