2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-23 20:40:40 +03:00

fix(types): resolve type discrepancies between ESM and CJS TypeScript declaration files (#6956)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
James Nail
2025-07-16 13:50:56 -04:00
committed by GitHub
parent a2214ca1bc
commit 8517aa16f8
+13 -2
View File
@@ -6,7 +6,7 @@ type MethodsHeaders = Partial<{
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders; [Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
} & {common: AxiosHeaders}>; } & {common: AxiosHeaders}>;
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean; type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any; type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;
@@ -77,6 +77,8 @@ declare class AxiosHeaders {
getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue; getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean; hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
getSetCookie(): string[];
[Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>; [Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
} }
@@ -97,6 +99,14 @@ declare class AxiosError<T = unknown, D = any> extends Error {
status?: number; status?: number;
toJSON: () => object; toJSON: () => object;
cause?: Error; cause?: Error;
static from<T = unknown, D = any>(
error: Error | unknown,
code?: string,
config?: axios.InternalAxiosRequestConfig<D>,
request?: any,
response?: axios.AxiosResponse<T, D>,
customProps?: object,
): AxiosError<T, D>;
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS"; static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE"; static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION"; static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
@@ -424,7 +434,7 @@ declare namespace axios {
// Alias // Alias
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>; type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig { interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
headers: AxiosRequestHeaders; headers: AxiosRequestHeaders;
} }
@@ -542,6 +552,7 @@ declare namespace axios {
formToJSON(form: GenericFormData|GenericHTMLFormElement): object; formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter; getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
AxiosHeaders: typeof AxiosHeaders; AxiosHeaders: typeof AxiosHeaders;
mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
} }
} }