From 28a06e6d95b6a8d4f65148743683e85b90719352 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 6 Oct 2021 20:10:01 +0200 Subject: [PATCH] Distinguish request and response data types (#4116) Co-authored-by: Jay --- index.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/index.d.ts b/index.d.ts index a71d03e..27c3361 100644 --- a/index.d.ts +++ b/index.d.ts @@ -47,7 +47,7 @@ export interface TransitionalOptions{ clarifyTimeoutError: boolean; } -export interface AxiosRequestConfig { +export interface AxiosRequestConfig { url?: string; method?: Method; baseURL?: string; @@ -56,7 +56,7 @@ export interface AxiosRequestConfig { headers?: Record; params?: any; paramsSerializer?: (params: any) => string; - data?: T; + data?: D; timeout?: number; timeoutErrorMessage?: string; withCredentials?: boolean; @@ -81,20 +81,20 @@ export interface AxiosRequestConfig { signal?: AbortSignal; } -export interface AxiosResponse { +export interface AxiosResponse { data: T; status: number; statusText: string; headers: Record; - config: AxiosRequestConfig; + config: AxiosRequestConfig; request?: any; } -export interface AxiosError extends Error { - config: AxiosRequestConfig; +export interface AxiosError extends Error { + config: AxiosRequestConfig; code?: string; request?: any; - response?: AxiosResponse; + response?: AxiosResponse; isAxiosError: boolean; toJSON: () => object; } @@ -143,14 +143,14 @@ export class Axios { response: AxiosInterceptorManager; }; getUri(config?: AxiosRequestConfig): string; - request> (config: AxiosRequestConfig): Promise; - get>(url: string, config?: AxiosRequestConfig): Promise; - delete>(url: string, config?: AxiosRequestConfig): Promise; - head>(url: string, config?: AxiosRequestConfig): Promise; - options>(url: string, config?: AxiosRequestConfig): Promise; - post>(url: string, data?: T, config?: AxiosRequestConfig): Promise; - put>(url: string, data?: T, config?: AxiosRequestConfig): Promise; - patch>(url: string, data?: T, 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 {