mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
fix(types): renamed RawAxiosRequestConfig back to AxiosRequestConfig; (#5486)
This commit is contained in:
+46
-43
@@ -4,13 +4,9 @@ interface RawAxiosHeaders {
|
||||
[key: string]: AxiosHeaderValue;
|
||||
}
|
||||
|
||||
type MethodsHeaders = {
|
||||
type MethodsHeaders = Partial<{
|
||||
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
|
||||
};
|
||||
|
||||
interface CommonHeaders {
|
||||
common: AxiosHeaders;
|
||||
}
|
||||
} & {common: AxiosHeaders}>;
|
||||
|
||||
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
|
||||
|
||||
@@ -79,12 +75,12 @@ declare class AxiosError<T = unknown, D = any> extends Error {
|
||||
constructor(
|
||||
message?: string,
|
||||
code?: string,
|
||||
config?: axios.AxiosRequestConfig<D>,
|
||||
config?: axios.InternalAxiosRequestConfig<D>,
|
||||
request?: any,
|
||||
response?: axios.AxiosResponse<T, D>
|
||||
);
|
||||
|
||||
config?: axios.AxiosRequestConfig<D>;
|
||||
config?: axios.InternalAxiosRequestConfig<D>;
|
||||
code?: string;
|
||||
request?: any;
|
||||
response?: axios.AxiosResponse<T, D>;
|
||||
@@ -110,24 +106,24 @@ declare class CanceledError<T> extends AxiosError<T> {
|
||||
}
|
||||
|
||||
declare class Axios {
|
||||
constructor(config?: axios.RawAxiosRequestConfig);
|
||||
constructor(config?: axios.AxiosRequestConfig);
|
||||
defaults: axios.AxiosDefaults;
|
||||
interceptors: {
|
||||
request: axios.AxiosInterceptorManager<axios.AxiosRequestConfig>;
|
||||
request: axios.AxiosInterceptorManager<axios.InternalAxiosRequestConfig>;
|
||||
response: axios.AxiosInterceptorManager<axios.AxiosResponse>;
|
||||
};
|
||||
getUri(config?: axios.RawAxiosRequestConfig): string;
|
||||
request<T = any, R = axios.AxiosResponse<T>, D = any>(config: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
postForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
putForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
patchForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.RawAxiosRequestConfig<D>): Promise<R>;
|
||||
getUri(config?: axios.AxiosRequestConfig): string;
|
||||
request<T = any, R = axios.AxiosResponse<T>, D = any>(config: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
postForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
putForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
patchForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
}
|
||||
|
||||
declare enum HttpStatusCode {
|
||||
@@ -203,30 +199,34 @@ declare namespace axios {
|
||||
|
||||
type CommonRequestHeadersList = 'Accept' | 'Content-Type' | 'Content-Length' | 'User-Agent'| 'Content-Encoding';
|
||||
|
||||
type RawCommonRequestHeaders = {
|
||||
type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {
|
||||
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
||||
}>;
|
||||
|
||||
type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
||||
|
||||
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';
|
||||
|
||||
type RawCommonResponseHeaders = {
|
||||
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
||||
} & {
|
||||
"set-cookie": string[];
|
||||
};
|
||||
|
||||
type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
|
||||
|
||||
type AxiosRequestHeaders = Partial<RawCommonRequestHeaders & RawAxiosHeaders> & AxiosHeaders;
|
||||
|
||||
type RawAxiosResponseHeaders = Partial<Record<string, string> & {
|
||||
"set-cookie"?: string[]
|
||||
}>;
|
||||
type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
|
||||
|
||||
type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
||||
|
||||
interface AxiosRequestTransformer {
|
||||
(this: AxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
||||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
||||
}
|
||||
|
||||
interface AxiosResponseTransformer {
|
||||
(this: AxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
||||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
||||
}
|
||||
|
||||
interface AxiosAdapter {
|
||||
(config: AxiosRequestConfig): AxiosPromise;
|
||||
(config: InternalAxiosRequestConfig): AxiosPromise;
|
||||
}
|
||||
|
||||
interface AxiosBasicCredentials {
|
||||
@@ -355,13 +355,13 @@ declare namespace axios {
|
||||
|
||||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
||||
|
||||
interface RawAxiosRequestConfig<D = any> {
|
||||
interface AxiosRequestConfig<D = any> {
|
||||
url?: string;
|
||||
method?: Method | string;
|
||||
baseURL?: string;
|
||||
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
||||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
||||
headers?: RawAxiosRequestHeaders | AxiosHeaders;
|
||||
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
||||
params?: any;
|
||||
paramsSerializer?: ParamsSerializerOptions;
|
||||
data?: D;
|
||||
@@ -397,7 +397,10 @@ declare namespace axios {
|
||||
formSerializer?: FormSerializerOptions;
|
||||
}
|
||||
|
||||
interface AxiosRequestConfig<D = any> extends RawAxiosRequestConfig {
|
||||
// Alias
|
||||
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
||||
|
||||
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
|
||||
headers: AxiosRequestHeaders;
|
||||
}
|
||||
|
||||
@@ -415,11 +418,11 @@ declare namespace axios {
|
||||
unlink?: RawAxiosRequestHeaders;
|
||||
}
|
||||
|
||||
interface AxiosDefaults<D = any> extends Omit<RawAxiosRequestConfig<D>, 'headers'> {
|
||||
interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||
headers: HeadersDefaults;
|
||||
}
|
||||
|
||||
interface CreateAxiosDefaults<D = any> extends Omit<RawAxiosRequestConfig<D>, 'headers'> {
|
||||
interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
||||
}
|
||||
|
||||
@@ -428,7 +431,7 @@ declare namespace axios {
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
||||
config: AxiosRequestConfig<D>;
|
||||
config: InternalAxiosRequestConfig<D>;
|
||||
request?: any;
|
||||
}
|
||||
|
||||
@@ -443,7 +446,7 @@ declare namespace axios {
|
||||
}
|
||||
|
||||
interface Canceler {
|
||||
(message?: string, config?: RawAxiosRequestConfig, request?: any): void;
|
||||
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
||||
}
|
||||
|
||||
interface CancelTokenStatic {
|
||||
@@ -464,7 +467,7 @@ declare namespace axios {
|
||||
|
||||
interface AxiosInterceptorOptions {
|
||||
synchronous?: boolean;
|
||||
runWhen?: (config: AxiosRequestConfig) => boolean;
|
||||
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
||||
}
|
||||
|
||||
interface AxiosInterceptorManager<V> {
|
||||
@@ -474,8 +477,8 @@ declare namespace axios {
|
||||
}
|
||||
|
||||
interface AxiosInstance extends Axios {
|
||||
<T = any, R = AxiosResponse<T>, D = any>(config: RawAxiosRequestConfig<D>): Promise<R>;
|
||||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: RawAxiosRequestConfig<D>): Promise<R>;
|
||||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
|
||||
defaults: Omit<AxiosDefaults, 'headers'> & {
|
||||
headers: HeadersDefaults & {
|
||||
|
||||
Reference in New Issue
Block a user