From 46abbcd0fcf88f283682d5be752f09afe7f6b4ee Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 1 Oct 2021 14:43:44 +0200 Subject: [PATCH] Revert "Improved type-safety for AxiosRequestConfig (#2995)" This reverts commit 4eeb3b17e28581e6931ad7b78dcc025cf3f99bc8. --- index.d.ts | 22 +++++++++++----------- test/typescript/axios.ts | 22 +++++++++------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/index.d.ts b/index.d.ts index a71d03e3ed..0499bb5b43 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?: any; timeout?: number; timeoutErrorMessage?: string; withCredentials?: boolean; @@ -86,7 +86,7 @@ export interface AxiosResponse { status: number; statusText: string; headers: Record; - config: AxiosRequestConfig; + config: AxiosRequestConfig; request?: any; } @@ -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> (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?: any, config?: AxiosRequestConfig): Promise; + put>(url: string, data?: any, config?: AxiosRequestConfig): Promise; + patch>(url: string, data?: any, config?: AxiosRequestConfig): Promise; } export interface AxiosInstance extends Axios { diff --git a/test/typescript/axios.ts b/test/typescript/axios.ts index 999b3630bc..d7724cb585 100644 --- a/test/typescript/axios.ts +++ b/test/typescript/axios.ts @@ -111,10 +111,6 @@ axios.patch('/user', { foo: 'bar' }) .catch(handleError); // Typed methods -interface UserCreationDef { - name: string; -} - interface User { id: number; name: string; @@ -142,7 +138,7 @@ axios.get('/user', { params: { id: 12345 } }) axios.head('/user') .then(handleUserResponse) .catch(handleError); - + axios.options('/user') .then(handleUserResponse) .catch(handleError); @@ -151,19 +147,19 @@ axios.delete('/user') .then(handleUserResponse) .catch(handleError); -axios.post('/user', { name: 'foo', id: 1 }) +axios.post('/user', { foo: 'bar' }) .then(handleUserResponse) .catch(handleError); -axios.post('/user', { name: 'foo', id: 1 }, { headers: { 'X-FOO': 'bar' } }) +axios.post('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } }) .then(handleUserResponse) .catch(handleError); -axios.put('/user', { name: 'foo', id: 1 }) +axios.put('/user', { foo: 'bar' }) .then(handleUserResponse) .catch(handleError); -axios.patch('/user', { name: 'foo', id: 1 }) +axios.patch('/user', { foo: 'bar' }) .then(handleUserResponse) .catch(handleError); @@ -193,19 +189,19 @@ axios.delete('/user') .then(handleStringResponse) .catch(handleError); -axios.post, string>('/user', { name: 'foo' }) +axios.post('/user', { foo: 'bar' }) .then(handleStringResponse) .catch(handleError); -axios.post, string>('/user', { name: 'foo' }, { headers: { 'X-FOO': 'bar' } }) +axios.post('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } }) .then(handleStringResponse) .catch(handleError); -axios.put, string>('/user', { name: 'foo' }) +axios.put('/user', { foo: 'bar' }) .then(handleStringResponse) .catch(handleError); -axios.patch, string>('/user', { name: 'foo' }) +axios.patch('/user', { foo: 'bar' }) .then(handleStringResponse) .catch(handleError);