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

TypeScript 5.5+ declaration of AbortSignal conflicts with Node.js v14 types #61447

Closed
siddharthvp opened this issue Mar 19, 2025 · 4 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@siddharthvp
Copy link

siddharthvp commented Mar 19, 2025

🔎 Search Terms

Steps to reproduce:

mkdir typescript-5-node-14
cd typescript-5-node-14
npm i typescript @types/node@14
touch index.ts
npx tsc index.ts

As of writing, this installs TypeScript 5.8.2 and @types/node 14.18.63.

🕗 Version & Regression Information

  • This changed between versions 5.4 and 5.5
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

🙁 Actual behavior

node_modules/@types/node/globals.d.ts:126:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; any(signals: AbortSignal[]): AbortSignal; timeout(milliseconds: number): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; timeout(milliseconds: number): AbortSignal; }'.

126 declare var AbortSignal: {
                ~~~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:2606:13
    2606 declare var AbortSignal: {
                     ~~~~~~~~~~~
    'AbortSignal' was also declared here.


Found 1 error in node_modules/@types/node/globals.d.ts:126

🙂 Expected behavior

Compilation without errors.

Additional information about the issue

It works fine if TypeScript <= 5.4 is used.

@siddharthvp siddharthvp changed the title TypeScript 5 declaration of AbortSignal conflicts with Node.js v14 types TypeScript 5.5+ declaration of AbortSignal conflicts with Node.js v14 types Mar 19, 2025
@nmain
Copy link

nmain commented Mar 19, 2025

lib.dom.d.ts describes the types of a fully compliant web browser (the HTML platform). @types/node describes the types of a full Node.js environment. I wouldn't expect the two to be compatible, and there is no real js environment that perfectly 100% implements both of these at the same time.

This feels like a duplicate of or closely related to #43972.

@siddharthvp
Copy link
Author

Ok, but why is TypeScript including lib.dom.d.ts by default? It's not needed for projects that solely target node.js. Is there a way to turn it off?

@MartinJohns
Copy link
Contributor

Legacy reasons. Browser used to be the default target for people's code.

https://www.typescriptlang.org/tsconfig/#lib

You may want to change these for a few reasons:
Your program doesn’t run in a browser, so you don’t want the "dom" type definitions

@typescript-bot
Copy link
Collaborator

This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

5 participants