mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Change never type to unknown (#4142)
* Distinguish request and response data types * Change never type to unknown Using `never` was a workaround I introduced in 3002, because `unknown` wasn’t supperted by all relevant versions of TypeScript at the time. It is now, and it is much more correct. Co-authored-by: Claas Augner <github@caugner.de> Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Vendored
+11
-11
@@ -81,7 +81,7 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosResponse<T = never, D = any> {
|
export interface AxiosResponse<T = unknown, D = any> {
|
||||||
data: T;
|
data: T;
|
||||||
status: number;
|
status: number;
|
||||||
statusText: string;
|
statusText: string;
|
||||||
@@ -90,7 +90,7 @@ export interface AxiosResponse<T = never, D = any> {
|
|||||||
request?: any;
|
request?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosError<T = never, D = any> extends Error {
|
export interface AxiosError<T = unknown, D = any> extends Error {
|
||||||
config: AxiosRequestConfig<D>;
|
config: AxiosRequestConfig<D>;
|
||||||
code?: string;
|
code?: string;
|
||||||
request?: any;
|
request?: any;
|
||||||
@@ -99,7 +99,7 @@ export interface AxiosError<T = never, D = any> extends Error {
|
|||||||
toJSON: () => object;
|
toJSON: () => object;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosPromise<T = never> extends Promise<AxiosResponse<T>> {
|
export interface AxiosPromise<T = unknown> extends Promise<AxiosResponse<T>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CancelStatic {
|
export interface CancelStatic {
|
||||||
@@ -143,14 +143,14 @@ export class Axios {
|
|||||||
response: AxiosInterceptorManager<AxiosResponse>;
|
response: AxiosInterceptorManager<AxiosResponse>;
|
||||||
};
|
};
|
||||||
getUri(config?: AxiosRequestConfig): string;
|
getUri(config?: AxiosRequestConfig): string;
|
||||||
request<T = never, R = AxiosResponse<T>, D = any> (config: AxiosRequestConfig<D>): Promise<R>;
|
request<T = unknown, R = AxiosResponse<T>, D = any> (config: AxiosRequestConfig<D>): Promise<R>;
|
||||||
get<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
get<T = unknown, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
delete<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
delete<T = unknown, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
head<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
head<T = unknown, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
options<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
options<T = unknown, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
post<T = never, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
post<T = unknown, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
put<T = never, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
put<T = unknown, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
patch<T = never, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
patch<T = unknown, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInstance extends Axios {
|
export interface AxiosInstance extends Axios {
|
||||||
|
|||||||
Reference in New Issue
Block a user