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

Issues compiling CDK projects ("TS2300: Duplicate identifier 'IteratorResult'") #3839

Closed
RomainMuller opened this issue Aug 28, 2019 · 1 comment · Fixed by #3840
Closed
Assignees
Labels
bug This issue is a bug. package/tools Related to AWS CDK Tools or CLI

Comments

@RomainMuller
Copy link
Contributor

RomainMuller commented Aug 28, 2019

Applications created using the current "init templates" for TypeScript may fail building with the following error message:

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

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

node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.

41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
        ~~~~~~~~~~~~~~

  node_modules/@types/node/index.d.ts:97:11
    97 interface IteratorResult<T> { }
                 ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.

This can be fixed by removing the @types/node dependency declared in package.json, or upgrading it from 8.10.45 to 8.10.52, by running the following command:

$ npm install @types/node@8
+ @types/node@8.10.52
updated 1 package and audited 558 packages in 2.961s
found 0 vulnerabilities
@RomainMuller RomainMuller self-assigned this Aug 28, 2019
@RomainMuller RomainMuller added bug This issue is a bug. package/tools Related to AWS CDK Tools or CLI labels Aug 28, 2019
@RomainMuller RomainMuller pinned this issue Aug 28, 2019
RomainMuller added a commit that referenced this issue Aug 28, 2019
That was not required anymore since we no longer require passing the
command line arguments to the `app.run()` call. This dependency has the
potential of causing collisions with the ES libraries included by the
TypeScript compiler, and specifying a correct version can be a delicate
exercise, especially as those templates have to keep working in the
future.

Additionally, pinned the TypeScript compiler version to the current
minor, as recommended by the TypeScript maintainers (TypeScript does not
honor SemVer, but guarantees no breaking change between stable releases,
which they indicate by issuing a new major version).

Fixes #3839
@mergify mergify bot closed this as completed in #3840 Aug 28, 2019
mergify bot pushed a commit that referenced this issue Aug 28, 2019
* fix(init-templates): remove dependency on @types/node

That was not required anymore since we no longer require passing the
command line arguments to the `app.run()` call. This dependency has the
potential of causing collisions with the ES libraries included by the
TypeScript compiler, and specifying a correct version can be a delicate
exercise, especially as those templates have to keep working in the
future.

Additionally, pinned the TypeScript compiler version to the current
minor, as recommended by the TypeScript maintainers (TypeScript does not
honor SemVer, but guarantees no breaking change between stable releases,
which they indicate by issuing a new major version).

Fixes #3839

* also pin typescript compiler version to current minor
@shivlaks shivlaks unpinned this issue Aug 31, 2019
@fernard
Copy link

fernard commented Sep 19, 2019

Doesn't work for me, it still throws the same error as before.
This is my package.json file:

{
  "name": "node-ts-app",
  "version": "1.0.0",
  "description": "",
  "main": "src/server.ts",
  "scripts": {
    "start:dev": "nodemon --watch src/**/*.ts --exec ts-node src/server.ts",
    "build": "tsc",
    "lint": "eslint ./src/**/*.ts",
    "db:clear": "ts-node dev-data/data/manage-dev-data.ts --delete",
    "db:addAll": "ts-node dev-data/data/manage-dev-data.ts --import",
    "prettier": "prettier --write ./src/**/*.ts"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cross-env": "^5.2.1",
    "dotenv": "^8.1.0",
    "express": "^4.17.1",
    "lodash": "^4.17.15",
    "mongoose": "^5.7.1",
    "morgan": "^1.9.1"
  },
  "devDependencies": {
    "@types/express": "^4.17.1",
    "@types/lodash": "^4.14.138",
    "@types/mongoose": "^5.5.17",
    "@types/node": "^8.10.54",
    "@typescript-eslint/eslint-plugin": "^2.3.0",
    "@typescript-eslint/parser": "^2.3.0",
    "eslint": "^6.4.0",
    "nodemon": "^1.19.2",
    "prettier": "^1.18.2",
    "ts-node": "^8.4.1",
    "typescript": "^3.6.3"
  }
}

eladb pushed a commit that referenced this issue Nov 11, 2019
Since it is very common for users to need to reference local files using `path.join` and `__dirname`, it is only pragmatic that we will include @types/node in the init template.

We use a pinned version since experience shows that these types can get a bit messed up (see #3839)

Supersedes #4462
Reverts #3840
mergify bot pushed a commit that referenced this issue Nov 11, 2019
Since it is very common for users to need to reference local files using `path.join` and `__dirname`, it is only pragmatic that we will include @types/node in the init template.

We use a pinned version since experience shows that these types can get a bit messed up (see #3839)

Supersedes #4462
Reverts #3840
jimrandomh added a commit to ForumMagnum/ForumMagnum that referenced this issue Dec 6, 2019
kgregory-chariot added a commit to chariotsolutions/aws-examples that referenced this issue Dec 27, 2019
kgregory-chariot added a commit to chariotsolutions/aws-examples that referenced this issue Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants