Skip to content

Commit 8517aa1

Browse files
fix(types): resolve type discrepancies between ESM and CJS TypeScript declaration files (#6956)
Co-authored-by: Jay <[email protected]>
1 parent a2214ca commit 8517aa1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

index.d.cts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type MethodsHeaders = Partial<{
66
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
77
} & {common: AxiosHeaders}>;
88

9-
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
9+
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
1010

1111
type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;
1212

@@ -77,6 +77,8 @@ declare class AxiosHeaders {
7777
getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
7878
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
7979

80+
getSetCookie(): string[];
81+
8082
[Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
8183
}
8284

@@ -97,6 +99,14 @@ declare class AxiosError<T = unknown, D = any> extends Error {
9799
status?: number;
98100
toJSON: () => object;
99101
cause?: Error;
102+
static from<T = unknown, D = any>(
103+
error: Error | unknown,
104+
code?: string,
105+
config?: axios.InternalAxiosRequestConfig<D>,
106+
request?: any,
107+
response?: axios.AxiosResponse<T, D>,
108+
customProps?: object,
109+
): AxiosError<T, D>;
100110
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
101111
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
102112
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
@@ -424,7 +434,7 @@ declare namespace axios {
424434
// Alias
425435
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
426436

427-
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
437+
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
428438
headers: AxiosRequestHeaders;
429439
}
430440

@@ -542,6 +552,7 @@ declare namespace axios {
542552
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
543553
getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
544554
AxiosHeaders: typeof AxiosHeaders;
555+
mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
545556
}
546557
}
547558

0 commit comments

Comments
 (0)