mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +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:
Vendored
+8
-1
@@ -72,6 +72,13 @@ export interface TransitionalOptions {
|
|||||||
clarifyTimeoutError?: boolean;
|
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> {
|
export interface AxiosRequestConfig<D = any> {
|
||||||
url?: string;
|
url?: string;
|
||||||
method?: Method | string;
|
method?: Method | string;
|
||||||
@@ -105,7 +112,7 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
cancelToken?: CancelToken;
|
cancelToken?: CancelToken;
|
||||||
decompress?: boolean;
|
decompress?: boolean;
|
||||||
transitional?: TransitionalOptions;
|
transitional?: TransitionalOptions;
|
||||||
signal?: AbortSignal;
|
signal?: GenericAbortSignal;
|
||||||
insecureHTTPParser?: boolean;
|
insecureHTTPParser?: boolean;
|
||||||
env?: {
|
env?: {
|
||||||
FormData?: new (...args: any[]) => object;
|
FormData?: new (...args: any[]) => object;
|
||||||
|
|||||||
@@ -375,3 +375,7 @@ axios.get('/user')
|
|||||||
// FormData
|
// FormData
|
||||||
|
|
||||||
axios.toFormData({x: 1}, new FormData());
|
axios.toFormData({x: 1}, new FormData());
|
||||||
|
|
||||||
|
// AbortSignal
|
||||||
|
|
||||||
|
axios.get('/user', {signal: new AbortController().signal});
|
||||||
|
|||||||
Reference in New Issue
Block a user