axios 1.18.1 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.cts CHANGED
@@ -52,6 +52,10 @@ declare class AxiosHeaders {
52
52
  set(headers?: axios.RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
53
53
  set(headers?: Iterable<[string, axios.AxiosHeaderValue]>, rewrite?: boolean): AxiosHeaders;
54
54
 
55
+ get(
56
+ headerName: string,
57
+ parser: typeof AxiosHeaders.parseParameters
58
+ ): axios.AxiosHeaderParameters;
55
59
  get(headerName: string, parser: RegExp): RegExpExecArray | null;
56
60
  get(headerName: string, matcher?: true | AxiosHeaderParser): axios.AxiosHeaderValue;
57
61
 
@@ -73,6 +77,8 @@ declare class AxiosHeaders {
73
77
 
74
78
  static from(thing?: AxiosHeaders | axios.RawAxiosHeaders | string): AxiosHeaders;
75
79
 
80
+ static parseParameters(value: axios.AxiosHeaderValue): axios.AxiosHeaderParameters;
81
+
76
82
  static accessor(header: string | string[]): AxiosHeaders;
77
83
 
78
84
  static concat(
@@ -125,32 +131,32 @@ declare class AxiosHeaders {
125
131
  [Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
126
132
  }
127
133
 
128
- declare class AxiosError<T = unknown, D = any> extends Error {
134
+ declare class AxiosError<T = unknown, D = any, P = any> extends Error {
129
135
  constructor(
130
136
  message?: string,
131
137
  code?: string,
132
- config?: axios.InternalAxiosRequestConfig<D>,
138
+ config?: axios.InternalAxiosRequestConfig<D, P>,
133
139
  request?: any,
134
- response?: axios.AxiosResponse<T, D>
140
+ response?: axios.AxiosResponse<T, D, {}, P>
135
141
  );
136
142
 
137
- config?: axios.InternalAxiosRequestConfig<D>;
143
+ config?: axios.InternalAxiosRequestConfig<D, P>;
138
144
  code?: string;
139
145
  request?: any;
140
- response?: axios.AxiosResponse<T, D>;
146
+ response?: axios.AxiosResponse<T, D, {}, P>;
141
147
  isAxiosError: boolean;
142
148
  status?: number;
143
149
  toJSON: () => object;
144
150
  cause?: Error;
145
151
  event?: BrowserProgressEvent;
146
- static from<T = unknown, D = any>(
152
+ static from<T = unknown, D = any, P = any>(
147
153
  error: Error | unknown,
148
154
  code?: string,
149
- config?: axios.InternalAxiosRequestConfig<D>,
155
+ config?: axios.InternalAxiosRequestConfig<D, P>,
150
156
  request?: any,
151
- response?: axios.AxiosResponse<T, D>,
157
+ response?: axios.AxiosResponse<T, D, {}, P>,
152
158
  customProps?: object
153
- ): AxiosError<T, D>;
159
+ ): AxiosError<T, D, P>;
154
160
  static readonly ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
155
161
  static readonly ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
156
162
  static readonly ERR_BAD_OPTION = 'ERR_BAD_OPTION';
@@ -167,12 +173,20 @@ declare class AxiosError<T = unknown, D = any> extends Error {
167
173
  static readonly ETIMEDOUT = 'ETIMEDOUT';
168
174
  }
169
175
 
170
- declare class CanceledError<T> extends AxiosError<T> {
171
- constructor(message?: string, config?: axios.InternalAxiosRequestConfig, request?: any);
176
+ declare class CanceledError<T, D = any, P = any> extends AxiosError<T, D, P> {
177
+ constructor(message?: string, config?: axios.InternalAxiosRequestConfig<D, P>, request?: any);
172
178
  readonly name: 'CanceledError';
173
179
  __CANCEL__?: boolean;
174
180
  }
175
181
 
182
+ declare const axiosResponseDefault: unique symbol;
183
+
184
+ type AxiosResponseDefault = typeof axiosResponseDefault;
185
+
186
+ type AxiosResponseResult<T, R, D, P> = R extends AxiosResponseDefault
187
+ ? axios.AxiosResponse<T, D, {}, P>
188
+ : R;
189
+
176
190
  declare class Axios {
177
191
  constructor(config?: axios.AxiosRequestConfig);
178
192
  defaults: axios.AxiosDefaults;
@@ -181,60 +195,60 @@ declare class Axios {
181
195
  response: axios.AxiosInterceptorManager<axios.AxiosResponse>;
182
196
  };
183
197
  getUri(config?: axios.AxiosRequestConfig): string;
184
- request<T = any, R = axios.AxiosResponse<T>, D = any>(
185
- config: axios.AxiosRequestConfig<D>
186
- ): Promise<R>;
187
- get<T = any, R = axios.AxiosResponse<T>, D = any>(
198
+ request<T = any, R = AxiosResponseDefault, D = any, P = any>(
199
+ config: axios.AxiosRequestConfig<D, P>
200
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
201
+ get<T = any, R = AxiosResponseDefault, D = any, P = any>(
188
202
  url: string,
189
- config?: axios.AxiosRequestConfig<D>
190
- ): Promise<R>;
191
- delete<T = any, R = axios.AxiosResponse<T>, D = any>(
203
+ config?: axios.AxiosRequestConfig<D, P>
204
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
205
+ delete<T = any, R = AxiosResponseDefault, D = any, P = any>(
192
206
  url: string,
193
- config?: axios.AxiosRequestConfig<D>
194
- ): Promise<R>;
195
- head<T = any, R = axios.AxiosResponse<T>, D = any>(
207
+ config?: axios.AxiosRequestConfig<D, P>
208
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
209
+ head<T = any, R = AxiosResponseDefault, D = any, P = any>(
196
210
  url: string,
197
- config?: axios.AxiosRequestConfig<D>
198
- ): Promise<R>;
199
- options<T = any, R = axios.AxiosResponse<T>, D = any>(
211
+ config?: axios.AxiosRequestConfig<D, P>
212
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
213
+ options<T = any, R = AxiosResponseDefault, D = any, P = any>(
200
214
  url: string,
201
- config?: axios.AxiosRequestConfig<D>
202
- ): Promise<R>;
203
- post<T = any, R = axios.AxiosResponse<T>, D = any>(
215
+ config?: axios.AxiosRequestConfig<D, P>
216
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
217
+ post<T = any, R = AxiosResponseDefault, D = any, P = any>(
204
218
  url: string,
205
219
  data?: D,
206
- config?: axios.AxiosRequestConfig<D>
207
- ): Promise<R>;
208
- put<T = any, R = axios.AxiosResponse<T>, D = any>(
220
+ config?: axios.AxiosRequestConfig<D, P>
221
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
222
+ put<T = any, R = AxiosResponseDefault, D = any, P = any>(
209
223
  url: string,
210
224
  data?: D,
211
- config?: axios.AxiosRequestConfig<D>
212
- ): Promise<R>;
213
- patch<T = any, R = axios.AxiosResponse<T>, D = any>(
225
+ config?: axios.AxiosRequestConfig<D, P>
226
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
227
+ patch<T = any, R = AxiosResponseDefault, D = any, P = any>(
214
228
  url: string,
215
229
  data?: D,
216
- config?: axios.AxiosRequestConfig<D>
217
- ): Promise<R>;
218
- postForm<T = any, R = axios.AxiosResponse<T>, D = any>(
230
+ config?: axios.AxiosRequestConfig<D, P>
231
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
232
+ postForm<T = any, R = AxiosResponseDefault, D = any, P = any>(
219
233
  url: string,
220
234
  data?: D,
221
- config?: axios.AxiosRequestConfig<D>
222
- ): Promise<R>;
223
- putForm<T = any, R = axios.AxiosResponse<T>, D = any>(
235
+ config?: axios.AxiosRequestConfig<D, P>
236
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
237
+ putForm<T = any, R = AxiosResponseDefault, D = any, P = any>(
224
238
  url: string,
225
239
  data?: D,
226
- config?: axios.AxiosRequestConfig<D>
227
- ): Promise<R>;
228
- patchForm<T = any, R = axios.AxiosResponse<T>, D = any>(
240
+ config?: axios.AxiosRequestConfig<D, P>
241
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
242
+ patchForm<T = any, R = AxiosResponseDefault, D = any, P = any>(
229
243
  url: string,
230
244
  data?: D,
231
- config?: axios.AxiosRequestConfig<D>
232
- ): Promise<R>;
233
- query<T = any, R = axios.AxiosResponse<T>, D = any>(
245
+ config?: axios.AxiosRequestConfig<D, P>
246
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
247
+ query<T = any, R = AxiosResponseDefault, D = any, P = any>(
234
248
  url: string,
235
249
  data?: D,
236
- config?: axios.AxiosRequestConfig<D>
237
- ): Promise<R>;
250
+ config?: axios.AxiosRequestConfig<D, P>
251
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
238
252
  }
239
253
 
240
254
  declare enum HttpStatusCode {
@@ -301,6 +315,7 @@ declare enum HttpStatusCode {
301
315
  LoopDetected = 508,
302
316
  NotExtended = 510,
303
317
  NetworkAuthenticationRequired = 511,
318
+ WebServerReturnsAnUnknownError = 520,
304
319
  WebServerIsDown = 521,
305
320
  ConnectionTimedOut = 522,
306
321
  OriginIsUnreachable = 523,
@@ -309,10 +324,12 @@ declare enum HttpStatusCode {
309
324
  InvalidSslCertificate = 526,
310
325
  }
311
326
 
312
- type InternalAxiosError<T = unknown, D = any> = AxiosError<T, D>;
327
+ type InternalAxiosError<T = unknown, D = any, P = any> = AxiosError<T, D, P>;
313
328
 
314
329
  declare namespace axios {
315
- type AxiosError<T = unknown, D = any> = InternalAxiosError<T, D>;
330
+ type AxiosHeaderParameters = Record<string, string>;
331
+
332
+ type AxiosError<T = unknown, D = any, P = any> = InternalAxiosError<T, D, P>;
316
333
 
317
334
  interface RawAxiosHeaders {
318
335
  [key: string]: AxiosHeaderValue;
@@ -450,13 +467,13 @@ declare namespace axios {
450
467
  (value: any, defaultEncoder: (value: any) => any): any;
451
468
  }
452
469
 
453
- interface CustomParamsSerializer {
454
- (params: Record<string, any>, options?: ParamsSerializerOptions): string;
470
+ interface CustomParamsSerializer<P = Record<string, any>> {
471
+ (params: P, options?: ParamsSerializerOptions<P>): string;
455
472
  }
456
473
 
457
- interface ParamsSerializerOptions extends SerializerOptions {
474
+ interface ParamsSerializerOptions<P = Record<string, any>> extends SerializerOptions {
458
475
  encode?: ParamEncoder;
459
- serialize?: CustomParamsSerializer;
476
+ serialize?: CustomParamsSerializer<P>;
460
477
  }
461
478
 
462
479
  type MaxUploadRate = number;
@@ -491,7 +508,7 @@ declare namespace axios {
491
508
 
492
509
  type LookupAddress = string | LookupAddressEntry;
493
510
 
494
- interface AxiosRequestConfig<D = any> {
511
+ interface AxiosRequestConfig<D = any, P = any> {
495
512
  url?: string;
496
513
  method?: Method | string;
497
514
  baseURL?: string;
@@ -499,8 +516,10 @@ declare namespace axios {
499
516
  transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
500
517
  transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
501
518
  headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
502
- params?: any;
503
- paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
519
+ params?: P;
520
+ paramsSerializer?:
521
+ | ParamsSerializerOptions<unknown extends P ? Record<string, any> : P>
522
+ | CustomParamsSerializer<unknown extends P ? Record<string, any> : P>;
504
523
  data?: D;
505
524
  timeout?: Milliseconds;
506
525
  timeoutErrorMessage?: string;
@@ -562,7 +581,7 @@ declare namespace axios {
562
581
  | [address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily]
563
582
  | LookupAddress
564
583
  >);
565
- withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
584
+ withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig<D, P>) => boolean | undefined);
566
585
  parseReviver?: (this: any, key: string, value: any, context?: { source?: string }) => any;
567
586
  fetchOptions?:
568
587
  | Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'>
@@ -577,9 +596,9 @@ declare namespace axios {
577
596
  }
578
597
 
579
598
  // Alias
580
- type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
599
+ type RawAxiosRequestConfig<D = any, P = any> = AxiosRequestConfig<D, P>;
581
600
 
582
- interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
601
+ interface InternalAxiosRequestConfig<D = any, P = any> extends AxiosRequestConfig<D, P> {
583
602
  headers: AxiosRequestHeaders;
584
603
  }
585
604
 
@@ -598,24 +617,27 @@ declare namespace axios {
598
617
  query?: RawAxiosRequestHeaders;
599
618
  }
600
619
 
601
- interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
620
+ interface AxiosDefaults<D = any, P = any> extends Omit<AxiosRequestConfig<D, P>, 'headers'> {
602
621
  headers: HeadersDefaults;
603
622
  }
604
623
 
605
- interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
624
+ interface CreateAxiosDefaults<D = any, P = any> extends Omit<
625
+ AxiosRequestConfig<D, P>,
626
+ 'headers'
627
+ > {
606
628
  headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
607
629
  }
608
630
 
609
- interface AxiosResponse<T = any, D = any, H = {}> {
631
+ interface AxiosResponse<T = any, D = any, H = {}, P = any> {
610
632
  data: T;
611
633
  status: number;
612
634
  statusText: string;
613
635
  headers: (H & RawAxiosResponseHeaders) | AxiosResponseHeaders;
614
- config: InternalAxiosRequestConfig<D>;
636
+ config: InternalAxiosRequestConfig<D, P>;
615
637
  request?: any;
616
638
  }
617
639
 
618
- type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
640
+ type AxiosPromise<T = any, D = any, P = any> = Promise<AxiosResponse<T, D, {}, P>>;
619
641
 
620
642
  interface CancelStatic {
621
643
  new (message?: string): Cancel;
@@ -682,11 +704,13 @@ declare namespace axios {
682
704
  }
683
705
 
684
706
  interface AxiosInstance extends Axios {
685
- <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
686
- <T = any, R = AxiosResponse<T>, D = any>(
707
+ <T = any, R = AxiosResponseDefault, D = any, P = any>(
708
+ config: AxiosRequestConfig<D, P>
709
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
710
+ <T = any, R = AxiosResponseDefault, D = any, P = any>(
687
711
  url: string,
688
- config?: AxiosRequestConfig<D>
689
- ): Promise<R>;
712
+ config?: AxiosRequestConfig<D, P>
713
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
690
714
 
691
715
  create(config?: CreateAxiosDefaults): AxiosInstance;
692
716
  defaults: Omit<AxiosDefaults, 'headers'> & {
@@ -714,10 +738,10 @@ declare namespace axios {
714
738
  CanceledError: typeof CanceledError;
715
739
  HttpStatusCode: typeof HttpStatusCode;
716
740
  readonly VERSION: string;
717
- isCancel<T = any>(value: any): value is CanceledError<T>;
741
+ isCancel<T = any, D = any, P = any>(value: any): value is CanceledError<T, D, P>;
718
742
  all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
719
743
  spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
720
- isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
744
+ isAxiosError<T = any, D = any, P = any>(payload: any): payload is AxiosError<T, D, P>;
721
745
  toFormData(
722
746
  sourceObj: object,
723
747
  targetFormData?: GenericFormData,
@@ -726,10 +750,10 @@ declare namespace axios {
726
750
  formToJSON(form: GenericFormData | GenericHTMLFormElement): object;
727
751
  getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
728
752
  AxiosHeaders: typeof AxiosHeaders;
729
- mergeConfig<D = any>(
730
- config1: AxiosRequestConfig<D>,
731
- config2: AxiosRequestConfig<D>
732
- ): AxiosRequestConfig<D>;
753
+ mergeConfig<D = any, P = any>(
754
+ config1: AxiosRequestConfig<D, P>,
755
+ config2: AxiosRequestConfig<D, P>
756
+ ): AxiosRequestConfig<D, P>;
733
757
  }
734
758
  }
735
759
 
package/index.d.ts CHANGED
@@ -3,6 +3,8 @@ type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
3
3
 
4
4
  export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
5
5
 
6
+ export type AxiosHeaderParameters = Record<string, string>;
7
+
6
8
  export interface RawAxiosHeaders {
7
9
  [key: string]: AxiosHeaderValue;
8
10
  }
@@ -33,6 +35,7 @@ export class AxiosHeaders {
33
35
  set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
34
36
  set(headers?: Iterable<[string, AxiosHeaderValue]>, rewrite?: boolean): AxiosHeaders;
35
37
 
38
+ get(headerName: string, parser: typeof AxiosHeaders.parseParameters): AxiosHeaderParameters;
36
39
  get(headerName: string, parser: RegExp): RegExpExecArray | null;
37
40
  get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
38
41
 
@@ -54,6 +57,8 @@ export class AxiosHeaders {
54
57
 
55
58
  static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
56
59
 
60
+ static parseParameters(value: AxiosHeaderValue): AxiosHeaderParameters;
61
+
57
62
  static accessor(header: string | string[]): AxiosHeaders;
58
63
 
59
64
  static concat(
@@ -236,6 +241,7 @@ export enum HttpStatusCode {
236
241
  LoopDetected = 508,
237
242
  NotExtended = 510,
238
243
  NetworkAuthenticationRequired = 511,
244
+ WebServerReturnsAnUnknownError = 520,
239
245
  WebServerIsDown = 521,
240
246
  ConnectionTimedOut = 522,
241
247
  OriginIsUnreachable = 523,
@@ -335,13 +341,13 @@ export interface ParamEncoder {
335
341
  (value: any, defaultEncoder: (value: any) => any): any;
336
342
  }
337
343
 
338
- export interface CustomParamsSerializer {
339
- (params: Record<string, any>, options?: ParamsSerializerOptions): string;
344
+ export interface CustomParamsSerializer<P = Record<string, any>> {
345
+ (params: P, options?: ParamsSerializerOptions<P>): string;
340
346
  }
341
347
 
342
- export interface ParamsSerializerOptions extends SerializerOptions {
348
+ export interface ParamsSerializerOptions<P = Record<string, any>> extends SerializerOptions {
343
349
  encode?: ParamEncoder;
344
- serialize?: CustomParamsSerializer;
350
+ serialize?: CustomParamsSerializer<P>;
345
351
  }
346
352
 
347
353
  type MaxUploadRate = number;
@@ -378,7 +384,7 @@ export interface LookupAddressEntry {
378
384
 
379
385
  export type LookupAddress = string | LookupAddressEntry;
380
386
 
381
- export interface AxiosRequestConfig<D = any> {
387
+ export interface AxiosRequestConfig<D = any, P = any> {
382
388
  url?: string;
383
389
  method?: StringLiteralsOrString<Method>;
384
390
  baseURL?: string;
@@ -386,8 +392,10 @@ export interface AxiosRequestConfig<D = any> {
386
392
  transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
387
393
  transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
388
394
  headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
389
- params?: any;
390
- paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
395
+ params?: P;
396
+ paramsSerializer?:
397
+ | ParamsSerializerOptions<unknown extends P ? Record<string, any> : P>
398
+ | CustomParamsSerializer<unknown extends P ? Record<string, any> : P>;
391
399
  data?: D;
392
400
  timeout?: Milliseconds;
393
401
  timeoutErrorMessage?: string;
@@ -455,7 +463,7 @@ export interface AxiosRequestConfig<D = any> {
455
463
  ) => Promise<
456
464
  [address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress
457
465
  >);
458
- withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
466
+ withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig<D, P>) => boolean | undefined);
459
467
  parseReviver?: (this: any, key: string, value: any, context?: { source?: string }) => any;
460
468
  fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
461
469
  httpVersion?: 1 | 2;
@@ -468,9 +476,9 @@ export interface AxiosRequestConfig<D = any> {
468
476
  }
469
477
 
470
478
  // Alias
471
- export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
479
+ export type RawAxiosRequestConfig<D = any, P = any> = AxiosRequestConfig<D, P>;
472
480
 
473
- export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
481
+ export interface InternalAxiosRequestConfig<D = any, P = any> extends AxiosRequestConfig<D, P> {
474
482
  headers: AxiosRequestHeaders;
475
483
  }
476
484
 
@@ -489,49 +497,52 @@ export interface HeadersDefaults {
489
497
  query?: RawAxiosRequestHeaders;
490
498
  }
491
499
 
492
- export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
500
+ export interface AxiosDefaults<D = any, P = any> extends Omit<AxiosRequestConfig<D, P>, 'headers'> {
493
501
  headers: HeadersDefaults;
494
502
  }
495
503
 
496
- export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
504
+ export interface CreateAxiosDefaults<D = any, P = any> extends Omit<
505
+ AxiosRequestConfig<D, P>,
506
+ 'headers'
507
+ > {
497
508
  headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
498
509
  }
499
510
 
500
- export interface AxiosResponse<T = any, D = any, H = {}> {
511
+ export interface AxiosResponse<T = any, D = any, H = {}, P = any> {
501
512
  data: T;
502
513
  status: number;
503
514
  statusText: string;
504
515
  headers: (H & RawAxiosResponseHeaders) | AxiosResponseHeaders;
505
- config: InternalAxiosRequestConfig<D>;
516
+ config: InternalAxiosRequestConfig<D, P>;
506
517
  request?: any;
507
518
  }
508
519
 
509
- export class AxiosError<T = unknown, D = any> extends Error {
520
+ export class AxiosError<T = unknown, D = any, P = any> extends Error {
510
521
  constructor(
511
522
  message?: string,
512
523
  code?: string,
513
- config?: InternalAxiosRequestConfig<D>,
524
+ config?: InternalAxiosRequestConfig<D, P>,
514
525
  request?: any,
515
- response?: AxiosResponse<T, D>
526
+ response?: AxiosResponse<T, D, {}, P>
516
527
  );
517
528
 
518
- config?: InternalAxiosRequestConfig<D>;
529
+ config?: InternalAxiosRequestConfig<D, P>;
519
530
  code?: string;
520
531
  request?: any;
521
- response?: AxiosResponse<T, D>;
532
+ response?: AxiosResponse<T, D, {}, P>;
522
533
  isAxiosError: boolean;
523
534
  status?: number;
524
535
  toJSON: () => object;
525
536
  cause?: Error;
526
537
  event?: BrowserProgressEvent;
527
- static from<T = unknown, D = any>(
538
+ static from<T = unknown, D = any, P = any>(
528
539
  error: Error | unknown,
529
540
  code?: string,
530
- config?: InternalAxiosRequestConfig<D>,
541
+ config?: InternalAxiosRequestConfig<D, P>,
531
542
  request?: any,
532
- response?: AxiosResponse<T, D>,
543
+ response?: AxiosResponse<T, D, {}, P>,
533
544
  customProps?: object
534
- ): AxiosError<T, D>;
545
+ ): AxiosError<T, D, P>;
535
546
  static readonly ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
536
547
  static readonly ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
537
548
  static readonly ERR_BAD_OPTION = 'ERR_BAD_OPTION';
@@ -548,13 +559,21 @@ export class AxiosError<T = unknown, D = any> extends Error {
548
559
  static readonly ETIMEDOUT = 'ETIMEDOUT';
549
560
  }
550
561
 
551
- export class CanceledError<T> extends AxiosError<T> {
552
- constructor(message?: string, config?: InternalAxiosRequestConfig, request?: any);
562
+ export class CanceledError<T, D = any, P = any> extends AxiosError<T, D, P> {
563
+ constructor(message?: string, config?: InternalAxiosRequestConfig<D, P>, request?: any);
553
564
  readonly name: 'CanceledError';
554
565
  __CANCEL__?: boolean;
555
566
  }
556
567
 
557
- export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
568
+ declare const axiosResponseDefault: unique symbol;
569
+
570
+ type AxiosResponseDefault = typeof axiosResponseDefault;
571
+
572
+ type AxiosResponseResult<T, R, D, P> = R extends AxiosResponseDefault
573
+ ? AxiosResponse<T, D, {}, P>
574
+ : R;
575
+
576
+ export type AxiosPromise<T = any, D = any, P = any> = Promise<AxiosResponse<T, D, {}, P>>;
558
577
 
559
578
  export interface CancelStatic {
560
579
  new (message?: string): Cancel;
@@ -628,63 +647,70 @@ export class Axios {
628
647
  response: AxiosInterceptorManager<AxiosResponse>;
629
648
  };
630
649
  getUri(config?: AxiosRequestConfig): string;
631
- request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
632
- get<T = any, R = AxiosResponse<T>, D = any>(
650
+ request<T = any, R = AxiosResponseDefault, D = any, P = any>(
651
+ config: AxiosRequestConfig<D, P>
652
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
653
+ get<T = any, R = AxiosResponseDefault, D = any, P = any>(
633
654
  url: string,
634
- config?: AxiosRequestConfig<D>
635
- ): Promise<R>;
636
- delete<T = any, R = AxiosResponse<T>, D = any>(
655
+ config?: AxiosRequestConfig<D, P>
656
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
657
+ delete<T = any, R = AxiosResponseDefault, D = any, P = any>(
637
658
  url: string,
638
- config?: AxiosRequestConfig<D>
639
- ): Promise<R>;
640
- head<T = any, R = AxiosResponse<T>, D = any>(
659
+ config?: AxiosRequestConfig<D, P>
660
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
661
+ head<T = any, R = AxiosResponseDefault, D = any, P = any>(
641
662
  url: string,
642
- config?: AxiosRequestConfig<D>
643
- ): Promise<R>;
644
- options<T = any, R = AxiosResponse<T>, D = any>(
663
+ config?: AxiosRequestConfig<D, P>
664
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
665
+ options<T = any, R = AxiosResponseDefault, D = any, P = any>(
645
666
  url: string,
646
- config?: AxiosRequestConfig<D>
647
- ): Promise<R>;
648
- post<T = any, R = AxiosResponse<T>, D = any>(
667
+ config?: AxiosRequestConfig<D, P>
668
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
669
+ post<T = any, R = AxiosResponseDefault, D = any, P = any>(
649
670
  url: string,
650
671
  data?: D,
651
- config?: AxiosRequestConfig<D>
652
- ): Promise<R>;
653
- put<T = any, R = AxiosResponse<T>, D = any>(
672
+ config?: AxiosRequestConfig<D, P>
673
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
674
+ put<T = any, R = AxiosResponseDefault, D = any, P = any>(
654
675
  url: string,
655
676
  data?: D,
656
- config?: AxiosRequestConfig<D>
657
- ): Promise<R>;
658
- patch<T = any, R = AxiosResponse<T>, D = any>(
677
+ config?: AxiosRequestConfig<D, P>
678
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
679
+ patch<T = any, R = AxiosResponseDefault, D = any, P = any>(
659
680
  url: string,
660
681
  data?: D,
661
- config?: AxiosRequestConfig<D>
662
- ): Promise<R>;
663
- postForm<T = any, R = AxiosResponse<T>, D = any>(
682
+ config?: AxiosRequestConfig<D, P>
683
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
684
+ postForm<T = any, R = AxiosResponseDefault, D = any, P = any>(
664
685
  url: string,
665
686
  data?: D,
666
- config?: AxiosRequestConfig<D>
667
- ): Promise<R>;
668
- putForm<T = any, R = AxiosResponse<T>, D = any>(
687
+ config?: AxiosRequestConfig<D, P>
688
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
689
+ putForm<T = any, R = AxiosResponseDefault, D = any, P = any>(
669
690
  url: string,
670
691
  data?: D,
671
- config?: AxiosRequestConfig<D>
672
- ): Promise<R>;
673
- patchForm<T = any, R = AxiosResponse<T>, D = any>(
692
+ config?: AxiosRequestConfig<D, P>
693
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
694
+ patchForm<T = any, R = AxiosResponseDefault, D = any, P = any>(
674
695
  url: string,
675
696
  data?: D,
676
- config?: AxiosRequestConfig<D>
677
- ): Promise<R>;
678
- query<T = any, R = AxiosResponse<T>, D = any>(
697
+ config?: AxiosRequestConfig<D, P>
698
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
699
+ query<T = any, R = AxiosResponseDefault, D = any, P = any>(
679
700
  url: string,
680
701
  data?: D,
681
- config?: AxiosRequestConfig<D>
682
- ): Promise<R>;
702
+ config?: AxiosRequestConfig<D, P>
703
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
683
704
  }
684
705
 
685
706
  export interface AxiosInstance extends Axios {
686
- <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
687
- <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
707
+ <T = any, R = AxiosResponseDefault, D = any, P = any>(
708
+ config: AxiosRequestConfig<D, P>
709
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
710
+ <T = any, R = AxiosResponseDefault, D = any, P = any>(
711
+ url: string,
712
+ config?: AxiosRequestConfig<D, P>
713
+ ): Promise<AxiosResponseResult<T, R, D, P>>;
688
714
 
689
715
  create(config?: CreateAxiosDefaults): AxiosInstance;
690
716
  defaults: Omit<AxiosDefaults, 'headers'> & {
@@ -716,18 +742,20 @@ export function toFormData(
716
742
 
717
743
  export function formToJSON(form: GenericFormData | GenericHTMLFormElement): object;
718
744
 
719
- export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
745
+ export function isAxiosError<T = any, D = any, P = any>(
746
+ payload: any
747
+ ): payload is AxiosError<T, D, P>;
720
748
 
721
749
  export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
722
750
 
723
- export function isCancel<T = any>(value: any): value is CanceledError<T>;
751
+ export function isCancel<T = any, D = any, P = any>(value: any): value is CanceledError<T, D, P>;
724
752
 
725
753
  export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
726
754
 
727
- export function mergeConfig<D = any>(
728
- config1: AxiosRequestConfig<D>,
729
- config2: AxiosRequestConfig<D>
730
- ): AxiosRequestConfig<D>;
755
+ export function mergeConfig<D = any, P = any>(
756
+ config1: AxiosRequestConfig<D, P>,
757
+ config2: AxiosRequestConfig<D, P>
758
+ ): AxiosRequestConfig<D, P>;
731
759
 
732
760
  export function create(config?: CreateAxiosDefaults): AxiosInstance;
733
761