-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Duplicate identifier with @types/node 10.0 #25342
Comments
I was just about to log this same issue! I tried this:
I get these same errors. |
Adding additional mention for the latest author: @rbuckton. |
I am also seeing this. The last push broke our build with this same error. |
Also getting this. Looks like a conflict with Typescript in my case. |
Yes. In the OP's post, the conflict is with |
yep. seeing this as well. |
Experienced this issue as well, fixed by downgrading |
We're still using the latest LTS (8), so we solved this (for now) by using |
I will be able to look at this tonight. |
You can get an idea of the impact of this breaking change with @dependabot @rbuckton Thanks for looking into this 👍 |
Quick fix:
|
For old-fashioned guys with nodejs v6.x.x - |
This was broken because these classes were changed to be globally exported, line 2380 in the current file. See the history comparison below: bffb032#diff-7d84e08967cded0b99ed4328aab0a1a8 I was just about to pull and make the changes but looks like @rbuckton is already ahead of me in the process. |
@robertbradleyux In node 10.0.0, The URL class is also available on the global object so this seems correct. @rbuckton Is there a way to tell TypeScript to only define the class if it is not already defined? In this case, both node and the browser implement the same WHATWG URL Standard so this is similar to Somehow TypeScript is able to handle the Update I see there is already a pull request to revert this change #25356 |
After clearing my npm cache I am still getting the original error |
@kgorlick This won't show up until the types publisher publishes the updated types to npm. |
@styfle, NodeJS and DOM have slight differences in their implementations of the WHATWG URL standard (e.g. the NodeJS version has a |
Getting this error node_modules/@types/node/index.d.ts:75:15 - error TS2300: Duplicate identifier 'SharedArrayBuffer'. 75 declare class SharedArrayBuffer { node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts:24:11 node_modules/@types/node/index.d.ts:83:15 - error TS2451: Cannot redeclare block-scoped variable 'custom'. etc..... |
@Mulperi I think your issue is different to the above and related to the change of @SimonSchick I think this should be changed back as it is actually just a forward declaration. |
@Flarna this will only work if you load dom typings tho, node typings should work without loading dom typings.. |
It's not |
@Flarna would simply adding |
Also relevant since |
Nope as |
I'm also getting this problem. And changing to a previous version of |
@Flarna I'm currently travelling, could you perhaps look into this? |
@jmeberlein Which typescript version do you use? I expect it's <3.1. |
created #33177. Hard to tell when this get's merged as CI is in a bad state currently. |
Typescript version ^2.9.2 in package.json, resolving to 2.9.2 in npm-shrinkwrap.json |
why is this story closed? It seems to be broken still. |
This was resolved almost a year ago, so it seems it was fixed but has now regressed. I'd probably open a new issue. |
Problem still not resolved |
@thameurr Please note that you comment on an issue closed quite a while ago. I assume you use a different set of @types/node, typescript,... versions then that ones mentined in this issue. Could you create a new issue with instructions how to reproduced where up to date versions of the packages are used? |
I got this problem with
|
This issue was still occurring for me with TypeScript 4.0.2. Installing |
Got the same error. It's fixed when I add |
yarn run v1.22.17
$ .../project/node_modules/.bin/tsc
../node_modules/@types/node/buffer.d.ts:97:14 - error TS2661: Cannot export 'Buffer'. Only local declarations can be exported from a module.
97 export { Buffer };
~~~~~~
Found 1 error.
error Command failed with exit code 2 Related: #56043 |
If you know how to fix the issue, make a pull request instead.
@types/xxxx
package and had problems.Definitions by:
inindex.d.ts
) so they can respond.With v9.6.6 everything was fine with my Angular project. Upgraded to 10.0.0 and now I get the following errors running my unit tests:
Error: node_modules/@types/node/index.d.ts(2381,15): error TS2300: Duplicate identifier 'URL'. node_modules/@types/node/index.d.ts(2399,15): error TS2300: Duplicate identifier 'URLSearchParams'. node_modules/@types/node/index.d.ts(2417,14): error TS2661: Cannot export 'URL'. Only local declarations can be exported from a module. node_modules/@types/node/index.d.ts(2417,19): error TS2661: Cannot export 'URLSearchParams'. Only local declarations can be exported from a module. node_modules/typescript/lib/lib.dom.d.ts(12210,11): error TS2300: Duplicate identifier 'URL'. node_modules/typescript/lib/lib.dom.d.ts(12226,13): error TS2300: Duplicate identifier 'URL'. node_modules/typescript/lib/lib.dom.d.ts(14282,11): error TS2300: Duplicate identifier 'URLSearchParams'. node_modules/typescript/lib/lib.dom.d.ts(14309,13): error TS2300: Duplicate identifier 'URLSearchParams'.
The text was updated successfully, but these errors were encountered: