Aws-cdk: Issues compiling CDK projects ("TS2300: Duplicate identifier 'IteratorResult'")

Created on 28 Aug 2019  路  1Comment  路  Source: aws/aws-cdk

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/[email protected]
updated 1 package and audited 558 packages in 2.961s
found 0 vulnerabilities
bug packagtools

Most helpful comment

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"
  }
}

>All comments

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"
  }
}
Was this page helpful?
0 / 5 - 0 ratings