Skip to content

Usage of AbortController ist breaking for setup without DOM Library #4124

@smirowstanitzok

Description

@smirowstanitzok

Describe the bug

Axios has been using the AbortController from the DOM library since version 0.22.0 (# 3305). Since then, the DOM library has to be stored in tsconfig.json. Without DOM the new version is breaking for our setup and can no longer be used.

To Reproduce

Use axios.get() without DOM Library. To reproduce change tsconfig.json to eg.:

...
    "lib": ["ES2020"],
...

Expected behavior

axios should work without DOM. Maybe there is an alternative for AbortController?

Environment

  • Axios Version 0.22.0
  • Adapter http
  • Browser none
  • Node.js Version 14.18.0
  • OS: macOS 11.6

Additional context/Screenshots

Given Exception:

> @smirowstanitzok/trendytag-sdk@3.1.2 build /home/runner/work/trendytag-sdk/trendytag-sdk
> tsc

Error: node_modules/axios/index.d.ts(81,12): error TS2304: Cannot find name 'AbortSignal'.
Error: src/index.ts(189,13): error TS2322: Type 'unknown' is not assignable to type 'AxiosResponse<ContactFormResponse> | undefined'.
  Type 'unknown' is not assignable to type 'AxiosResponse<ContactFormResponse>'.
Error: src/index.ts(189,88): error TS2345: Argument of type 'ContactForm' is not assignable to parameter of type 'ContactFormResponse'.
  Property 'messageId' is missing in type 'ContactForm' but required in type 'ContactFormResponse'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @smirowstanitzok/trendytag-sdk@3.1.2 build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @smirowstanitzok/trendytag-sdk@3.1.2 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-10-01T08_27_20_612Z-debug.log
Error: Process completed with exit code 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions