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

Issue with TS4.9 - 'AbortSignal' was also declared here. #51567

Closed
jogibear9988 opened this issue Nov 16, 2022 · 34 comments
Closed

Issue with TS4.9 - 'AbortSignal' was also declared here. #51567

jogibear9988 opened this issue Nov 16, 2022 · 34 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@jogibear9988
Copy link

Bug Report

After upgradeing to Typescript 4.9 I get now this error.

  [20:27:02] Starting compilation in watch mode...
  
  node_modules/@types/node/globals.d.ts:72: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; timeout(milliseconds: number): AbortSignal; }', but here has type 
  '{ new (): AbortSignal; prototype: AbortSignal; timeout(milliseconds: number): AbortSignal; }'.
  
  72 declare var AbortSignal: {
                 ~~~~~~~~~~~
  
    node_modules/typescript/lib/lib.dom.d.ts:2071:13
      2071 declare var AbortSignal: {
                       ~~~~~~~~~~~
      'AbortSignal' was also declared here.
  
  [20:27:09] Found 1 error. Watching for file changes.
@jogibear9988
Copy link
Author

This are the packages in my package.json:

"dependencies": {
  "@node-projects/base-custom-webcomponent": "^0.10.3",
  "construct-style-sheets-polyfill": "^3.1.0"
},
"devDependencies": {
  "@node-projects/lean-he-esm": "^3.3.0",
  "@node-projects/node-html-parser-esm": "^2.4.1",
  "@papyrs/stylo": "^0.0.41",
  "@types/codemirror": "^5.60.5",
  "@types/jquery": "^3.5.14",
  "@types/jquery.fancytree": "0.0.7",
  "ace-builds": "^1.13.1",
  "codemirror": "^6.0.1",
  "esprima-next": "^5.8.4",
  "html2canvas": "*",
  "jest": "^29.3.1",
  "jquery": "^3.6.1",
  "jquery.fancytree": "^2.38.2",
  "monaco-editor": "^0.34.1",
  "ts-jest": "^29.0.3",
  "typescript": "^4.9.3",
  "typescript-lit-html-plugin": "^0.9.0"
},

@benmccann
Copy link
Contributor

I ran into this in my project with AbortController and fixed it by upgrading all my dependencies to the latest versions (sveltejs/kit#7657).

@melink14
Copy link

devblogs.microsoft.com/typescript/announcing-typescript-4-9/#correctness-changes

We don’t expect major breaks as a result of DOM and lib.d.ts updates, but there may be some small ones.

Why do you reference node AND dom types?

Wouldn't it be quite natural to reference both if you had a web project with node build scripts?

It looks like the goal is to fix it in the node types DefinitelyTyped/DefinitelyTyped#60868 but not sure how long that will take...

@jakebailey
Copy link
Member

jakebailey commented Nov 17, 2022

I'm pretty sure that this is just a case of needing to update types. We fixed this same issue in Monaco a week or so ago by updating deps.

If you don't depend on these directly, try relocking your project.

@melink14
Copy link

I agree. I saw there were open related issues so didn't verify but I see there are other closed issues which explicitly updated node types for 4.9. Thanks Jake!

@jogibear9988
Copy link
Author

I got this error at first after dooing a "npm-upgrade" (wich upgrades all packages i reference) and then doing a "npm i"

@melink14
Copy link

As Jake said, you may have a transitive dependency with out of date node types. In that case try to delete your lock file and then run npm i again. (relock as Jake put it)

@jogibear9988
Copy link
Author

I did this. I deleted the lock file.

@jogibear9988
Copy link
Author

fixed it by adding @types/node to my dev dependencies

  npm i -d @types/node

@melink14
Copy link

That's definitely strange and unexpected but without seeing your setup it's hard to say what went wrong. If you're okay keeping an unused dev dependency, that's probably a solid solution.

@jogibear9988
Copy link
Author

You see my setup. Above I posted every Dependecy I have.
The source I used is here: https://github.com/node-projects/web-component-designer

@melink14
Copy link

melink14 commented Nov 17, 2022

Took a quick look and it was a problem with transitive dependencies, I had not gotten the steps to properly refresh your lockfile correct. You also need to delete node_modules folder. Here's the steps I took in your repo:

  1. npx npm-upgrade and say yes to everything.
  2. 'npm i`
  3. npm run tsc and confirm error.
  4. rm package-lock.json
  5. rm -Rf node_modules/
  6. npm i
  7. npm run tsc -> no error!

@jogibear9988
Copy link
Author

Thanks
I thought a "npm i" was enough

@fatcerberus
Copy link

It used to be that not having lockfiles made dependency management hard. Now deleting the lockfile is a valid troubleshooting method to fix dependency issues. We've come full circle, ladies and gentlemen! 😄

@jogibear9988
Copy link
Author

yes, and now you also need to delete node_modules folder... this i found modt discusting

ArttuOll added a commit to react-hookz/web that referenced this issue Nov 17, 2022
…dencies

This relates to the release of TypeScript 4.9, which caused our build to break due to type errors.
As suggested in microsoft/TypeScript#51567, this is fixed by updating all
sub-dependencies of the project.
@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Nov 18, 2022
@typescript-bot
Copy link
Collaborator

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

sis0k0 added a commit to mongodb-developer/mean-stack-example that referenced this issue Nov 22, 2022
robinmetral pushed a commit to sumup-oss/circuit-ui that referenced this issue Nov 23, 2022
robinmetral pushed a commit to sumup-oss/circuit-ui that referenced this issue Nov 23, 2022
kodiakhq bot pushed a commit to sumup-oss/circuit-ui that referenced this issue Nov 23, 2022
* chore(deps-dev): bump typescript from 4.8.4 to 4.9.3

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.8.4 to 4.9.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.8.4...v4.9.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Install @types/node to fix TS issue

Ref: microsoft/TypeScript#51567

* Add @type/nodes to root package.json

These are the deps for Storybook. The build fails without.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robin Métral <robin.metral@sumup.com>
@GitGrv
Copy link

GitGrv commented Nov 23, 2022

QUICK FIX*
--------update all your dependencies ----

  1. npm i -g npm-check-updates
  2. ncu -u
  3. npm install

@fregante
Copy link

This may happen when another dependency installs an older @types/node version. Run this to find out which one it is:

npm ls @types/node

In my case I had @types/node@17.0.40 installed. So via @types/tape, so I uninstalled and then re-installed @types/tape.

You don't need to install @types/node directly. Doing a clean install without package-lock and node_modules might fix it. And/or npx npm-check-updates -u

@JenuelDev
Copy link

Thanks, I was able to fix mine:

yarn add @types/node -D

or

npm install @types/node -D

bafu added a commit to numbersprotocol/nit that referenced this issue Feb 13, 2023
microsoft/TypeScript#51567

Signed-off-by: Bofu Chen (bafu) <bofu@numbersprotocol.io>
@TierK
Copy link

TierK commented Mar 8, 2023

npm upgrade

Works 100%!

@ghost
Copy link

ghost commented Mar 16, 2023

These are the packages in my package.json:

"dependencies": {
  "@node-projects/base-custom-webcomponent": "^0.10.3",
  "construct-style-sheets-polyfill": "^3.1.0"
},
"devDependencies": {
  "@node-projects/lean-he-esm": "^3.3.0",
  "@node-projects/node-html-parser-esm": "^2.4.1",
  "@papyrs/stylo": "^0.0.41",
  "@types/codemirror": "^5.60.5",
  "@types/jquery": "^3.5.14",
  "@types/jquery.fancytree": "0.0.7",
  "ace-builds": "^1.13.1",
  "codemirror": "^6.0.1",
  "esprima-next": "^5.8.4",
  "html2canvas": "*",
  "jest": "^29.3.1",
  "jquery": "^3.6.1",
  "jquery.fancytree": "^2.38.2",
  "monaco-editor": "^0.34.1",
  "ts-jest": "^29.0.3",
  "typescript": "^4.9.3",
  "typescript-lit-html-plugin": "^0.9.0"
},

swiing added a commit to swiing/Bit-TypedArray that referenced this issue Mar 18, 2023
This also fixes a conflict between dependencies, as per
microsoft/TypeScript#51567
bafu added a commit to numbersprotocol/nit that referenced this issue Apr 27, 2023
Details: microsoft/TypeScript#51567

Signed-off-by: Bofu Chen (bafu) <bofu@numbersprotocol.io>
lawrence-forooghian added a commit to ably/ably-js that referenced this issue May 11, 2023
I want to use the `satsifies` operator introduced in 4.9 [1].

Ran `npm install typescript@4.9.5 typedoc@latest`, and then upgraded
@types/node to ^18.0.0, to fix [2].

The TypeScript upgrade introduced one compilation error, which I’ve
fixed here.

I’m targeting the v2 integration branch (which uses the latest webpack)
since trying to upgrade TypeScript on `main` is giving some webpack
errors that don’t seem worth trying to understand.

[1] https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator
[2] microsoft/TypeScript#51567
dbartholomae added a commit to dbartholomae/middy-middleware-json-error-handler that referenced this issue May 14, 2023
This requires a TypeScript update as the newest version requires TypeScript 4.7 or later, which in turn requires pinning the @types/node dependency to a new-enough version to avoid a bug.

See microsoft/TypeScript#51567
@kenny1983
Copy link

kenny1983 commented Jun 9, 2023

fixed it by adding @types/node to my dev dependencies

  npm i -d @types/node

This should be npm i -D @types/node (case is important!), but other than that, this works. Thanks!

@Sintayew4
Copy link

#51567

@Phil1216
Copy link

Phil1216 commented Aug 5, 2024

Fixed by deleting lockfile and node_modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests