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

User/docker tests broken with duplicate identifier IteratorResult #32333

Closed
sandersn opened this issue Jul 10, 2019 · 32 comments
Closed

User/docker tests broken with duplicate identifier IteratorResult #32333

sandersn opened this issue Jul 10, 2019 · 32 comments
Assignees
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@sandersn
Copy link
Member

#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.

@eamodio
Copy link

eamodio commented Aug 19, 2019

I'm seeing the same thing when I tried to move to 3.6.1-rc

    ERROR in C:/Users/Eric/code/vscode-gitlens/node_modules/@types/node/index.d.ts
    ERROR in C:/Users/Eric/code/vscode-gitlens/node_modules/@types/node/index.d.ts(177,11):
    TS2300: Duplicate identifier 'IteratorResult'.

    ERROR in C:/Users/Eric/code/vscode-gitlens/node_modules/typescript/lib/lib.es2015.iterable.d.ts
    ERROR in C:/Users/Eric/code/vscode-gitlens/node_modules/typescript/lib/lib.es2015.iterable.d.ts(41,6):
    TS2300: Duplicate identifier 'IteratorResult'.

@rbuckton
Copy link
Member

@eamodio You need to update the version of @types/node you are using as this has already been addressed in that types package.

@eamodio
Copy link

eamodio commented Aug 19, 2019

@rbuckton Excellent -- that worked! Thank you!

paulmelnikow added a commit to badges/shields that referenced this issue Sep 9, 2019
repo-ranger bot pushed a commit to badges/shields that referenced this issue Sep 9, 2019
* 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.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v3.5.3...v3.6.2)

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

* Add types/node and pin it

ref microsoft/TypeScript#32333
@JontyMC
Copy link

JontyMC commented Nov 6, 2019

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?

@guyellis
Copy link

guyellis commented Nov 6, 2019

@JontyMC where is the other location that it is defined? I just ran into that issue as well:

node_modules/@types/node/index.d.ts:169:11 - error TS2300: Duplicate identifier 'IteratorResult'.

169 interface IteratorResult<T> { }
              ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.

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?

@JontyMC
Copy link

JontyMC commented Nov 7, 2019

Yeah, that was the issue, thanks. I had:

"./node_modules/@types/**/*.d.ts"

If this helps anyone else, I'm using Aurelia, and had to remove the above from aurelia.json in transpiler > dtsSource.

Here's a good post that explains how type definitions work https://blog.angular-university.io/typescript-2-type-system-how-do-type-definitions-work-in-npm-when-to-use-types-and-why-what-are-compiler-opt-in-types/

@nealeu
Copy link

nealeu commented Nov 13, 2019

@eamodio You need to update the version of @types/node you are using as this has already been addressed in that types package.

@rbuckton Exactly where is this addressed already? IteratorResult is still there at: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/index.d.ts#L72

@nealeu
Copy link

nealeu commented Nov 13, 2019

@rbuckton we need a flag to disable this error. The release notes say we need to fix this on case-by-case basis, but we cannot fix it for libraries that we cannot control, so due to this one feature we cannot adopt Typescript 3.7.

Why can't we opt in to this behaviour as has been the case with other stricter checking changes?

@rbuckton
Copy link
Member

@nealeu this is handled by the "typesVersions" entry in package.json: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/50adc95acf873e714256074311353232fcc1b5ed/types/node/package.json#L4-L10

When 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 in node_modules/@types/node and encounter this package.json. This informs the compiler to redirect the request for node_modules/@types/node/index.d.ts to node_modules/@types/node/ts3.2/index.d.ts, which does not contain IteratorResult.

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.

@weswigham
Copy link
Member

weswigham commented Dec 9, 2019

The latest versions of the node declarations directly include the required lib, rather than forward declaring anything - are you sure? The latest version of node declarations quite literally do not include IteratorResult.

@ik-kaseya
Copy link

@weswigham One of the submodules stored the old version of @types/node. Updated it as well and error's gone. Thanks for your help!

eterna2 added a commit to e2forks/pipelines that referenced this issue Dec 23, 2019
eterna2 added a commit to e2forks/pipelines that referenced this issue Dec 26, 2019
k8s-ci-robot pushed a commit to kubeflow/pipelines that referenced this issue Jan 6, 2020
* 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.

* update @types/node because of microsoft/TypeScript#32333

* upgrade kubernete-client version to be compatible with new @types/node version

* fix bug: AWSInstanceProfileCredentials.profile() returns a promise not a string

* remove I prefix from interfaces. minor fixes on lint errors.

* fix format errors

* Added more unit tests, and minor fixes.

* Fix comment: GKS should be GKE

* use jest.resetAllMocks instead of reset each mock individually

* fix format for helper test
@mprinc
Copy link

mprinc commented Mar 12, 2020

Whow?! That really hearts! :)

I had an issue with obsoleted @types/nodes in the parent folder

Nevertheless, thanks @rbuckton and @weswigham to this issue thread was REALLY useful to track all possible scenarios of this really painful and recurring issue.

I would really love to see this extracted into a separate troubleshooting document :)

9034725985 added a commit to onewyoming/onewyoming that referenced this issue May 26, 2020
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Aug 31, 2020
@danieldanielecki
Copy link

@eamodio You need to update the version of @types/node you are using as this has already been addressed in that types package.

This issue can be closed, the StackOverflow question also suggests that it resolves this issue.

hschulz pushed a commit to remindgmbh/typescript-utility-lib that referenced this issue Nov 17, 2020
Jeffwan pushed a commit to Jeffwan/pipelines that referenced this issue Dec 9, 2020
* 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.

* update @types/node because of microsoft/TypeScript#32333

* upgrade kubernete-client version to be compatible with new @types/node version

* fix bug: AWSInstanceProfileCredentials.profile() returns a promise not a string

* remove I prefix from interfaces. minor fixes on lint errors.

* fix format errors

* Added more unit tests, and minor fixes.

* Fix comment: GKS should be GKE

* use jest.resetAllMocks instead of reset each mock individually

* fix format for helper test
@rbuckton
Copy link
Member

As mentioned, please refer to https://stackoverflow.com/questions/57331779/typescript-duplicate-identifier-iteratorresult if you are still experiencing problems.

@ankita219819
Copy link

I used type/node version 17.0.3
I still get the same error. Can you specify which version can be better.

Version:
npm : 6.13.4
angular: 8
node: v10.19.0
storybook angular: 6.0.12

@ankita219819
Copy link

I have used 17.0.3 version of type/node. The issue still persist. Can you specify which can be the best version to be used. Please help me out. Its urgent.

Version:
npm : 6.13.4
angular: 8
node: v10.19.0
storybook angular: 6.0.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests