|
| 1 | +// Matching type definitions for axios 0.18 |
| 2 | + |
| 3 | +import { |
| 4 | + AxiosRequestConfig, |
| 5 | + AxiosPromise, |
| 6 | + AxiosInterceptorManager, |
| 7 | + AxiosResponse, |
| 8 | +} from 'axios'; |
| 9 | + |
| 10 | +/** |
| 11 | + * In order to only expose the apiVersion and versioningStrategy to axios instances with |
| 12 | + * versioning. We had to copy over the types and redefine them with a custom |
| 13 | + * axios request config that has versioning fields defined in them. |
| 14 | + */ |
| 15 | + |
| 16 | +export interface AxiosRequestConfigWithVersioning extends AxiosRequestConfig { |
| 17 | + apiVersion?: string; |
| 18 | + versioningStrategy?: string; |
| 19 | + adapter?: AxiosAdapterWithVersioning; |
| 20 | +} |
| 21 | + |
| 22 | +export interface AxiosAdapterWithVersioning { |
| 23 | + (config: AxiosRequestConfigWithVersioning): AxiosPromise<any>; |
| 24 | +} |
| 25 | + |
| 26 | +export interface AxiosResponseWithVersioning<T = any> extends AxiosResponse { |
| 27 | + config: AxiosRequestConfigWithVersioning; |
| 28 | +} |
| 29 | + |
| 30 | +export interface AxiosErrorWithVersioning extends Error { |
| 31 | + config: AxiosRequestConfigWithVersioning; |
| 32 | +} |
| 33 | + |
| 34 | +export interface AxiosInstanceWithVersioning { |
| 35 | + (config: AxiosRequestConfigWithVersioning): AxiosPromise; |
| 36 | + (url: string, config?: AxiosRequestConfigWithVersioning): AxiosPromise; |
| 37 | + defaults: AxiosRequestConfigWithVersioning; |
| 38 | + interceptors: { |
| 39 | + request: AxiosInterceptorManager<AxiosRequestConfigWithVersioning>; |
| 40 | + response: AxiosInterceptorManager<AxiosResponseWithVersioning>; |
| 41 | + }; |
| 42 | + getUri(config?: AxiosRequestConfigWithVersioning): string; |
| 43 | + request<T = any, R = AxiosResponseWithVersioning<T>>(config: AxiosRequestConfigWithVersioning): Promise<R>; |
| 44 | + get<T = any, R = AxiosResponseWithVersioning<T>>(url: string, config?: AxiosRequestConfigWithVersioning): Promise<R>; |
| 45 | + delete<T = any, R = AxiosResponseWithVersioning<T>>(url: string, config?: AxiosRequestConfigWithVersioning): Promise<R>; |
| 46 | + head<T = any, R = AxiosResponseWithVersioning<T>>(url: string, config?: AxiosRequestConfigWithVersioning): Promise<R>; |
| 47 | + post<T = any, R = AxiosResponseWithVersioning<T>>(url: string, data?: any, config?: AxiosRequestConfigWithVersioning): Promise<R>; |
| 48 | + put<T = any, R = AxiosResponseWithVersioning<T>>(url: string, data?: any, config?: AxiosRequestConfigWithVersioning): Promise<R>; |
| 49 | + patch<T = any, R = AxiosResponseWithVersioning<T>>(url: string, data?: any, config?: AxiosRequestConfigWithVersioning): Promise<R>; |
| 50 | +} |
0 commit comments