Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill #4229

Merged
merged 14 commits into from May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.d.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions test/typescript/axios.ts
Expand Up @@ -375,3 +375,7 @@ axios.get('/user')
// FormData

axios.toFormData({x: 1}, new FormData());

// AbortSignal

axios.get('/user', {signal: new AbortController().signal});