TypeScript: User/docker tests broken with duplicate identifier IteratorResult
https://github.com/microsoft/TypeScript/pull/32324 shows some errors in the user tests with duplicate identifier IteratorResult between the es2015 lib and @types/node
. The docker tests also fail, probably for a similar reason.
#32303 should fix some of these errors; we should make sure that the docker tests compile without error since those are open source partner teams in microsoft. Not sure if the fix will be in our code or theirs.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 32 (14 by maintainers)
Links to this issue
Commits related to this issue
- Add types/node and pin it ref https://github.com/microsoft/TypeScript/issues/32333 — committed to badges/shields by paulmelnikow 5 years ago
- Build(deps-dev): bump typescript from 3.5.3 to 3.6.2 (#3967) * Build(deps-dev): bump typescript from 3.5.3 to 3.6.2 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.5.3 to 3.6.2. -... — committed to badges/shields by dependabot-preview[bot] 5 years ago
- Fixed: TS fail - https://github.com/microsoft/TypeScript/issues/32333#issuecomment-522408244 — committed to wdias/adapter-status by gihankarunarathne 5 years ago
- Fixed: TS fail - https://github.com/microsoft/TypeScript/issues/32333\#issuecomment-522408244 — committed to wdias/import-json-raw by gihankarunarathne 5 years ago
- Fixed: TS fail - https://github.com/microsoft/TypeScript/issues/32333\#issuecomment-522408244 — committed to wdias/adapter-query by gihankarunarathne 5 years ago
- Fixed: TS fail - https://github.com/microsoft/TypeScript/issues/32333\#issuecomment-522408244 — committed to wdias/export-json-raw by gihankarunarathne 5 years ago
- FIX Duplicate identifier 'IteratorResult' yarn add --dev @types/node Inspired by https://github.com/microsoft/TypeScript/issues/32333#issuecomment-522408244 — committed to squall-io/squall by SalathielGenese 5 years ago
- update @types/node because of https://github.com/microsoft/TypeScript/issues/32333 — committed to e2forks/pipelines by eterna2 5 years ago
- update @types/node because of https://github.com/microsoft/TypeScript/issues/32333 — committed to e2forks/pipelines by eterna2 5 years ago
- [Frontend] unit tests for node server (#2745) * Add unit tests for aws-helper and minio-helper. * Break up server.ts into app.ts and handlers/*.ts so that unit test can be written more easily. * up... — committed to kubeflow/pipelines by eterna2 4 years ago
- add thanks to github https://github.com/microsoft/TypeScript/issues/32333 — committed to onewyoming/onewyoming by 9034725985 4 years ago
- [BUGFIX] Duplicated identifier 'IteratorResult' https://github.com/microsoft/TypeScript/issues/32333 — committed to remindgmbh/typescript-utility-lib by deleted user 5 years ago
- [Frontend] unit tests for node server (#2745) * Add unit tests for aws-helper and minio-helper. * Break up server.ts into app.ts and handlers/*.ts so that unit test can be written more easily. * up... — committed to Jeffwan/pipelines by eterna2 4 years ago
@eamodio You need to update the version of
@types/node
you are using as this has already been addressed in that types package.I upgraded to typescript 3.7.2 today and now am seeing the same error:
node_modules\@types\node\index.d.ts(72,11): error TS2300: Duplicate identifier 'IteratorResult'
I have upgraded @types\node to latest (12.12.6), but still getting the error. Any suggestions?
@nealeu this is handled by the
"typesVersions"
entry in package.json: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/50adc95acf873e714256074311353232fcc1b5ed/types/node/package.json#L4-L10When the TypeScript compiler searches for types (either using the
"types"
entry in your compiler options or automatic type directive detection when an"types"
is not present), it will search innode_modules/@types/node
and encounter this package.json. This informs the compiler to redirect the request fornode_modules/@types/node/index.d.ts
tonode_modules/@types/node/ts3.2/index.d.ts
, which does not containIteratorResult
.However, if your build is configured such that you are explicitly adding
node_modules/@types/node/index.d.ts
(either via"files"
or"includes"
in your tsconfig.json), the compiler does not perform this redirection.@JontyMC where is the other location that it is defined? I just ran into that issue as well:
However, for me it was because I didn’t have @types/node installed in that project. For you I see that you already have this installed. Could it be a reference in your tsconfig lib prop that’s causing this? What do you have listed in there?
In general, unless something has a
/// <reference types="node" />
somewhere, if you have"types": []
then we shouldn’t be including the NodeJS types at all. We exclude"node_modules/**/*"
by default, so it shouldn’t be automatically included. One possibility might be in how your project is structured. Is yourtsconfig.json
in the same directory as yournode_modules
? If not, or if you have additionalnode_modules
directories underneath your project, then it is possible it could be included from there.You could try restricting your included files by adding an
"include": [...]
to your tsconfig to ensure you are only including your sources by default (i.e."include": ["src/**/*"]
):If the build then fails because it can’t resolve a NodeJS built-in module like “fs”, then you are moving in the right direction. You could then modify your
"types"
entry in tsconfig.json to"types": ["node"]
to ensure the NodeJS type definitions are included automatically, which should use the correct module resolution behavior.@weswigham One of the submodules stored the old version of
@types/node
. Updated it as well and error’s gone. Thanks for your help!@rbuckton it seems somehow I was stuck at
@types/node
10.10.x
and I just managed to fix it by updating to10.17.5
. Sorry!Sorry, I just noticed you mentioned running
ts-build
also results in the errors. I noticed you have"types": []
in your tsconfig.json. This tells the compiler to not generate automatic type references. How are your node types being referenced then? Are you using/// <reference types="node" />
in one of your source files?