2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-18 12:39:44 +03:00
Commit Graph

42 Commits

Author SHA1 Message Date
Remco Haszing abf954185a fix: fix TypeScript type definitions for commonjs (#5196)
This is done by duplicating `index.d.ts` into `index.d.cts`, and
modifying it for CommonJS. The same was done for type tests.

Unfortunately I was unable to find a way to re-use types without
drastically changing the code base.

To test this, a minimum TypeScript version of 4.7 is needed, so it has
been updated. The old types still work with older TypeScript versions.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-10 20:23:02 +02:00
Dmitriy Mozgovoy 0c3a1e9fde Refactored module exports; (#5162)
* Refactored build pipeline;
Added module exports tests;
Added missing ESM export for parity with Axios factory;
Added `toFormData`, `formToJSON`, `isAxiosError`, `spread`, `isCancel`, `all` as named export to `index.d.ts`;

* Added ESM entry test;

* Updated README.md `installing` section;

* Added TypeScript importing test;
Added missed `CanceledError` & `AxiosHeaders` to `AxiosStatic` interface;

* Exclude `/test/module/` from tslint;
2022-10-30 18:46:17 +02:00
ChronosMasterOfAllTime b0ebf9fcac Fix: Don't add null values to query string. (#5108)
* feat: add  boolean flag to mimic pre 1.x behavior for paramsSerializer custom function

* chore: update ParamsSerializer Readme

* fix: dont slice hash off URL if not appending params

* Omit nulls from formData serialization

* fix: dont add nulls or undefined values to arrays either

* readme update

* fix test

* chore: documentation

* chore: do TS properly

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-15 15:01:59 +02:00
Dmitriy Mozgovoy 9d4b016dde feat: added custom params serializer support; (#5113)
* Added custom params serializer support;

* Added missed semicolon;
Fixed allowUnknown option;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 22:12:10 +02:00
shingo.sasaki a6e40c3bb2 fix(type): add clear to AxiosInterceptorManager (#5010)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-06 08:16:27 +02:00
Willian Agostini 58ec93a95e Allow null indexes on formSerializer and paramsSerializer (#4960)
* test: Failed test

Param indexes from formSerializer and paramsSerializer receiving null

Closes #4959

* fix: Allow null to indexes in SerializerOptions

Closes #4959

Co-authored-by: Willian Agostini <willian.agostini@fleetcor.com.br>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-29 08:18:35 +02:00
Luca Pizzini 05338f4454 Removed unused imports (#4949)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-28 21:16:14 +02:00
Stephen Jennings 64906bd886 require interceptors to return values (#4874)
Fixes #4873

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-26 21:11:29 +02:00
Dmitriy Mozgovoy bdf493cf8b Axios ES2017 (#4787)
* Added AxiosHeaders class;

* Fixed README.md href;

* Fixed a potential bug with headers normalization;

* Fixed a potential bug with headers normalization;
Refactored accessor building routine;
Refactored default transforms;
Removed `normalizeHeaderName` helper;

* Added `Content-Length` accessor;
Added missed `has` accessor to TS types;

* Added `AxiosTransformStream` class;
Added progress capturing ability for node.js environment;
Added `maxRate` option to limit the data rate in node.js environment;
Refactored event handled by `onUploadProgress` && `onDownloadProgress` listeners in browser environment;
Added progress & data rate tests for the http adapter;
Added response stream aborting test;
Added a manual progress capture test for the browser;
Updated TS types;
Added TS tests;
Refactored request abort logic for the http adapter;
Added ability to abort the response stream;

* Remove `stream/promises` & `timers/promises` modules usage in tests;

* Use `abortcontroller-polyfill`;

* Fixed AxiosTransformStream dead-lock in legacy node versions;
Fixed CancelError emitting in streams;

* Reworked AxiosTransformStream internal logic to optimize memory consumption;
Added throwing an error if the request stream was silently destroying (without error) Refers to #3966;

* Treat the destruction of the request stream as a cancellation of the request;
Fixed tests;

* Emit `progress` event in the next tick;

* Initial refactoring;

* Refactored Mocha tests to use ESM;

* Refactored Karma tests to use rollup preprocessor & ESM;
Replaced grunt with gulp;
Improved dev scripts;
Added Babel for rollup build;

* Added default commonjs package export for Node build;
Added automatic contributors list generator for package.json;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-06-18 11:19:27 +02:00
Dmitriy Mozgovoy 934f390cc3 URL params serializer; (#4734)
* Refactored BuildURL helper to use URLSearchParams serializer;

* Updated typings;
Added TS test;
2022-05-25 08:16:38 +02:00
Lukas Hroch ac96144dd3 fix(types): allow to specify partial default headers for instance creation (#4185)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 20:03:05 +02:00
Spencer 9f6ba5ee43 Fixing instance.defaults.headers type (#4557)
* Fixing instance.defaults.headers type

* remove console.log()

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:12:53 +02:00
Dmitriy Mozgovoy 384b7e6994 Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill (#4229)
* Added generic `AxiosAbortSignal` TS interface to avoid importing AbortController polyfill;

* Renamed `AxiosAbortSignal` to `GenericAbortSignal` to use the same naming style as `GenericFormData`;

* Added TS test for `GenericAbortSignal` interface;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 21:23:01 +02:00
Dmitriy Mozgovoy c07998a621 Added generic TS types for the exposed toFormData helper; (#4668) 2022-05-03 20:29:50 +02:00
Rodry 2c9cc76ee9 revert: change type of AxiosResponse to any (#4186)
* revert: change type of AxiosResponse to any

* types: add back default types

My bad xD

* Remove redundant default params
2021-10-22 10:14:23 +02:00
Remco Haszing 94a9344799 Test types (#4140)
* Distinguish request and response data types

* Fix Axios headers type

`axios.headers` is not of the same type as `request.headers`, so a new type
`AxiosDefaults` was introduced

* Replace grunt-ts with dtslint

This asserts that the type definitions are valid in the specified TypeScript
version and above. This is the same tool that is used by DefinitelyTyped.

* Remove grunt-ts

* Restore typescript dependency

* Fix missing semicolons

Co-authored-by: Claas Augner <github@caugner.de>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 09:53:10 +02:00
Remco Haszing 92b29d2775 Make the default type of response data never (#3002)
This requires TypeScript users to explicitly define the type of the data they
are consuming.

Before this, data was `any` by default. This means TypeScript consumers didn’t
get type safety if they forgot to specify the type.

Technically this is a breaking change for TypeScript users, as this will report
errors if they forgot to specifiy the response type. The simplest workaround
would be to explicitly set the response type to `any`, so it’s not breaking
much.

The `unknown` type is probably a slightly better fit, but this requires
TypeScript ^3.

`data` is still `any` in the very specific use case mentioned in
https://github.com/microsoft/TypeScript/issues/38969

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 14:11:25 +02:00
Carlos Chida 4eeb3b17e2 Improved type-safety for AxiosRequestConfig (#2995)
* Improved type-safety for AxiosRequestConfig

- AxiosRequestConfig is now a generic type whose template corresponds to data

Signed-off-by: Carlos Chida <carlos.chida@starchitecture.eu>

* Fixed tests

- TS tests now match the behaviour described in the PR

Signed-off-by: Carlos Chida <carlos.chida@starchitecture.eu>

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 14:06:05 +02:00
Jason Kwok f472e5da5f Adding a type guard for AxiosError (#2949)
Co-authored-by: Jason Kwok <JasonHK@users.noreply.github.com>
2020-11-03 10:01:07 +02:00
Taemin Shin 3a8b87d48a Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled (#3200) 2020-10-20 08:04:44 +02:00
Benny Neugebauer c120f44d3d Fixing 'progressEvent' type (#2851)
* Fix 'progressEvent' type

* Update axios.ts
2020-03-28 17:51:42 +08:00
grumblerchester c98ce7d464 Adding tests for method options type definitions (#1996)
Update tests.

Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-03-07 14:10:34 +08:00
Gustavo López 6642ca9aa1 Add independent maxBodyLength option (#2781)
* Add independent option to set the maximum size of the request body

* Remove maxBodyLength check

* Update README

* Assert for error code and message
2020-03-06 21:55:19 +08:00
Stephan Schneider 73cab975f0 typings: allow custom return types
response interceptor might change the type from AxiosResponse to anything they like
2018-06-18 10:48:29 +02:00
Andrew Scott f9373e96f2 Added tests for additional type parameters 2018-03-07 22:17:44 -08:00
Evan Shortiss d07e648c30 Fixing type definitions so AxiosInstance can be invoked 2017-12-20 21:45:48 -08:00
Daniel Fischer b0dccc6f16 Updated TypeScript typings with generic type parameters for request methods & AxiosResponse 2017-08-29 20:53:49 +02:00
Nick Uraltsev 3704d57ed4 Removing Promise from axios typings in favor of built-in type declarations 2017-03-14 19:23:05 -07:00
Nick Uraltsev 3ddeae60e5 Getting rid of TypeScript output files 2016-10-24 18:24:36 -07:00
Nick Uraltsev 216e2a6787 Adding axios.isCancel method 2016-09-21 18:47:37 -07:00
Nick Uraltsev 2033ef3ad0 Adding TypeScript definitions for cancel tokens 2016-09-17 12:49:14 -07:00
Nick Uraltsev 20666942d6 Adding proxy to TypeScript definitions 2016-08-24 15:48:14 -07:00
Nick Uraltsev 96d7ac2a0c Replacing progress with onUploadProgress and onDownloadProgress in TypeScript definitions 2016-08-23 18:29:25 -07:00
Nick Uraltsev 2325216239 Updating TypeScript definition tests 2016-08-18 20:01:54 -07:00
Nick Uraltsev 48549c8de7 Updating TypeScript definitions for axios.all and axios.spread 2016-08-16 19:03:28 -07:00
Nick Uraltsev 9a5e77bf6e Adding TypeScript definitions for adapters 2016-08-16 10:49:32 -07:00
Nick Uraltsev 0664d9895a Adding TypeScript definitions for interceptors 2016-08-16 09:34:23 -07:00
Nick Uraltsev 5176dfdec5 Converting TypeScript definitions to ES2015 module syntax 2016-08-09 23:17:11 -07:00
Nick Uraltsev 4ac0fbd1c1 Rename axios.createNew to axios.create 2015-10-23 08:40:46 -07:00
Nick Uraltsev b10874fa67 Make axios instantiable 2015-10-03 09:38:16 -07:00
mzabriskie 2ce5aa77df Releasing 0.5.2 2015-03-13 17:13:41 -06:00
Bret Little 7753adde2c Add a TypeScript definition for Axios with included tests 2014-11-18 15:53:04 -07:00