2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

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>
This commit is contained in:
Dmitriy Mozgovoy
2022-05-04 22:23:01 +03:00
committed by GitHub
parent eaaab30442
commit 384b7e6994
2 changed files with 12 additions and 1 deletions
Vendored
+8 -1
View File
@@ -72,6 +72,13 @@ export interface TransitionalOptions {
clarifyTimeoutError?: boolean;
}
export interface GenericAbortSignal {
aborted: boolean;
onabort: ((...args: any) => any) | null;
addEventListener: (...args: any) => any;
removeEventListener: (...args: any) => any;
}
export interface AxiosRequestConfig<D = any> {
url?: string;
method?: Method | string;
@@ -105,7 +112,7 @@ export interface AxiosRequestConfig<D = any> {
cancelToken?: CancelToken;
decompress?: boolean;
transitional?: TransitionalOptions;
signal?: AbortSignal;
signal?: GenericAbortSignal;
insecureHTTPParser?: boolean;
env?: {
FormData?: new (...args: any[]) => object;
+4
View File
@@ -375,3 +375,7 @@ axios.get('/user')
// FormData
axios.toFormData({x: 1}, new FormData());
// AbortSignal
axios.get('/user', {signal: new AbortController().signal});