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

Type definition of AxiosRequestConfig.signal is incompatible to nodejs AbortController.signal #5015

Closed
CarstenLeue opened this issue Oct 5, 2022 · 1 comment · Fixed by #5021

Comments

@CarstenLeue
Copy link

CarstenLeue commented Oct 5, 2022

Appears in 1.0.0.

The nodejs TS definition of AbortController.signal is:

/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
interface AbortSignal {
    /**
     * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
     */
    readonly aborted: boolean;
}

but Axios 1.0.0 requires:

export interface GenericAbortSignal {
  aborted: boolean;
  onabort: ((...args: any) => any) | null;
  addEventListener: (...args: any) => any;
  removeEventListener: (...args: any) => any;
}

this is incompatible, the event listener messages are missing on the nodejs type definition.

@phloose
Copy link
Contributor

phloose commented Oct 25, 2022

Despite being closed and somehow addressed by #5021 this is still an issue when you try to build a Request object for usage in fetch with the GenericAbortSignal coming from AxiosRequestConfig:

Type 'GenericAbortSignal | undefined' is not assignable to type 'AbortSignal | null | undefined'.
  Type 'GenericAbortSignal' is missing the following properties from type 'AbortSignal': reason, throwIfAborted, dispatchEvent, prototype

This happens with Axios 1.1.3, TS 4.8.4 and Node 16.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants