Definitelytyped: @types/node , Cannot compile : node_modules/@types/node/index.d.ts(50,14): error TS2687: All declarations of 'iterator' must have identical modifiers.

Created on 10 Mar 2017  ·  41Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

Since 7.0.8, when using

node_modules/@types/node/index.d.ts(50,14): error TS2687: All declarations of 'iterator' must have identical modifiers.

Our tsconfig :

{ "compilerOptions": { "target": "es5", "module": "amd", "sourceMap": true, "strictNullChecks": true, "noImplicitAny": false, "noImplicitReturns": true, "noImplicitThis": false, "noUnusedParameters": false, "noUnusedLocals": true, "experimentalDecorators": false, "emitDecoratorMetadata": false, "removeComments": true, "outFile": "../js/ts.js" }, "exclude": [ "node_modules", "../node_modules", "../../node_modules" ] }

Conflicts is between @types/node line 50 and @types/core-js, line 504 (iterator:Symbol)

Most helpful comment

@harrietsCreativeDabblets you should be able to include the following in your project's devDependencies (within ng-start/package.json):

"@types/node": "7.0.7"

Since this satisfies the jspm-config semver it will ensure your version of @types/node gets locked to 7.0.7. Note that if this did not satisfy the jspm-config semver, you would end up with duplicate definitions.

Ensure you delete your node_modules and npm i after modifying your projects package.json.

All 41 comments

Same issue for me too. tsconfig:
{ "compilerOptions": { "allowJs": false, "target": "es5", "module": "commonjs", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "sourceMap": true, "noEmitHelpers": true, "noUnusedLocals": true, "noImplicitReturns": true, "noUnusedParameters": true, "baseUrl": ".", "paths": { "app": [ "src/app" ], "app/*": [ "src/app/*" ], "core": [ "src/core" ], "core/*": [ "src/core/*" ] }, "typeRoots": [ "node_modules/@types" ] }, "compileOnSave": false, "buildOnSave": false, "exclude": [ "node_modules" ] }

Obviously the readonly modifier before iterator, was a mistake. Or core-js is wrong.

Same issue here, all my builds broke overnight.
our tsconfig

{
  "compilerOptions": {
    "target": "ES5",
    "sourceMap": true,
    "typeRoots": [ "node_modules/@types/" ],
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "declaration": false,
    "watch": true
  },
  "compileOnSave": true,
  "include": [
    "src/**/*"
  ],
  "exclude": [
    ".vscode",
    "node_modules",
    "dist"
  ]
}

Also having this issue. We've fixed our @types/node version to 7.0.7 for the time being, which still works. Posting here primarily to track the issue.

We're also having this same issue. Broke everything.

+1 same issue.

Exactly same thing here.

Same here,
temporarily pinned to 7.0.7.

+1 same

i have the same issue.
Switch back to @types/node": "7.0.7" fixes the problem

works for me now with removing core-js and using @types/[email protected] and tsconfig: "lib": ["es7"]

Same here. Switch back to @types/node": "7.0.7" fixes the problem. Marked for track the progress.

Should be fixed by #15108. Note that you may need to change "lib" in your tsconfig as types such as Iterator are not provided by core-js any more.

@andy-ms what are you suggesting we should change "lib" to ?

@baywet What lib should be depends on your project. For example my project compiles to ES5 but needs core-js to polyfill some ES6 functionality. This is my lib:

"lib": [
  "es6"
  "dom"
]

Check out --lib in the compiler options docs.

what file exactly should I change the version of @types/node": "7.0.7"?
A directory search reveals I have 2 such entries:

image

which one do I change, or do I change both of them?

Those are both in node_modules, so presumably they aren't checked in and can't be changed directly. The installer tool you use (e.g. npm or jspm) should have documentation describing how to install packages and set their versions.
But as the above discussion indicates, it's best to use the most recent versions of all libraries, and correctly set --lib in your tsconfig.json.

A proper install will have a version with ^ as first char in package.json (s), in order to get the latest. Regarding @types and libs problems in general like the one mentioned here, once it is fixed, first remove all node_modules directories (main project path, clients path, etc.), then do npm install in each concerned directory, then launch tsc again (typically with a grunt or equivalent build file), to check everything is ok.
In pre production and production environnements, you may have to do the same.

@harrietsCreativeDabblets you should be able to include the following in your project's devDependencies (within ng-start/package.json):

"@types/node": "7.0.7"

Since this satisfies the jspm-config semver it will ensure your version of @types/node gets locked to 7.0.7. Note that if this did not satisfy the jspm-config semver, you would end up with duplicate definitions.

Ensure you delete your node_modules and npm i after modifying your projects package.json.

@pe8ter Thanks for the precision. I ended up upgrading to @types/[email protected] and made these changes in my tsconfig.json, thus keeping IE11 compatibility.

"lib": [
      "dom",
      "dom.iterable",
      "es2015",
      "scripthost"
    ],

Same Issue here; solved with 7.0.7 version downgrade

Same Issue here; solved with 7.0.7 version downgrade

It doesn't look like this was solved, and using version 7.0.7 forever isn't logical. Besides, pinning the versions didn't fix this for me. Nothing in this thread has.

@loctrice What is your TypeScript version from node_modules/typescript/package.json and node version from node_modules/@types/node/package.json?

typescript is 2.3.4 and node is 8.0.5

@loctrice I can't reproduce this with those versions. I'm in a blank directory and just installed those. What's in your tsconfig? Can you try to get a small repro?
By the way, did you mean 8.0.50 instead of 8.0.5? Tested with both though and didn't get an error.

I'm not sure what my tsconfig should be. I've been banging around on this after upgrading from the old typings to @types so I've been changing it based on threads I've seen, just seeing if anything works. This is my last error, and before earlier today I had no libs entered at all. Nothing I've added has made an effect:

{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"typeRoots": [
"./node_modules/@types"
],
"lib": [
"es2015",
"es6",
"dom",
"dom.iterable"
]
},

I can't reproduce an error with those installed versions and thattsconfig.json.

  • mkdir repro; cd repro`
  • paste that content to tsconfig.json (and add ending })
  • npm install @types/[email protected] [email protected]
  • echo "" > a.ts
  • node node_modules/typescript/lib/tsc.js
  • No error

This helps get me started trouble shooting. I'm going to start adding my typings one at a time to see where the problem is in my angular2 project.

it looks like this might be caused by the core-js and es6 typings I had installed. If I remove core-js then I get errors from features like "Promise is a type" that I fixed yesterday by pinning the version of core-js to 0.9.35. Here are my typings:

chai: "^4.0.4",
core-js: "0.9.35",
node: "^8.0.50",
openlayers: "^4.1.0",
systemjs: "^0.20.6",

It looks like the conflict is because in core-js on line 504 there is a definition for iterator: symboland in the node typings on line 54 there is a definition of readonly iterator: symbol changing either of these manually to match will get my project to compile.

I am trying to get angular2-electron-boilerplate updated and working. I am getting this error:

node_modules/@types/node/index.d.ts(79,14): error TS2687: All declarations of 'iterator' must have identical modifiers.

79     readonly iterator: symbol;
                ~~~~~~~~
phil@Loki ~/d/g/s/g/o/angular2-electron-boilerplate (master) [130]> 
grep -rnE 'iterator:\s+symbol' node_modules/
node_modules//@types/node/index.d.ts:79:    readonly iterator: symbol;
node_modules//typescript/lib/lib.es2015.iterable.d.ts:28:    readonly iterator: symbol;
node_modules//typescript/lib/lib.es6.d.ts:4763:    readonly iterator: symbol;
node_modules//reflect-metadata/Reflect.ts:95:    declare const Symbol: { iterator: symbol, toPrimitive: symbol };

Versions:

@philipbel did you figure it out?

Is there a permanent fix to the problem @loctrice describes?

No, I haven’t.

On 2 Jan 2018, at 2:11, Smackzter notifications@github.com wrote:

@philipbel did you figure it out?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@philipbel Looks like the problem is in reflect-metadata. Curious how you ended up compiling with Reflect.ts instead of Reflect.d.ts.

@loctrice by manually edit core-js my project can compiled but can we have a better solution?

tried with @ types/[email protected] worked well

@thanhngvpt I don't contribute to this project, so I can't provide a solution. I was eventually forced to upgrade my project, and with that most of the packages, and everything seemed fine.

To solve this

npm i [email protected] --save

My build is broke from no where!! This issue is still shown.

My env

Ionic:

   Ionic CLI          : 5.2.3 (C\\\\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.2

Cordova:

   Cordova CLI       : 8.0.0
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 20 other plugins)

Utility:

   cordova-res : 0.8.1
   native-run  : 1.0.0

System:

   Android SDK Tools : 26.1.1 (C:\\\\AppData\Local\Android\Sdk)
   NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10
Typescript is 2.5

Yeah, nothing I do seems to fix this issue. I don't have a lib definition in my tsconfig.json and I'm completely bewildered by the information provided in this thread. This is my tsconfig.json file:

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "rootDir": "src",
        "outDir": "out",
        "forceConsistentCasingInFileNames": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "pretty": true,
        "declaration": true
    }
}

Exactly what should I do about this that will stop producing the following compiler errors which I have absolutely no control over?

node_modules/vscode/vscode.d.ts:534:3 - error TS2687: All declarations of 'textEditor' must have identical modifiers.

534     textEditor: TextEditor;
        ~~~~~~~~~~

node_modules/vscode/vscode.d.ts:8363:3 - error TS2687: All declarations of 'body' must have identical modifiers.

8363    body?: any;
        ~~~~

Dependencies:

"devDependencies": {
  "@types/node": "^8.10.59",
  "@types/vscode": "^1.1.36",
  "rimraf": "^3.0.0",
  "tslint": "^5.20.1",
  "tslint-config-xo": "^2.0.0",
  "typescript": "^3.7.4",
  "vscode": "^1.1.36"
}

It seems like adding "skipLibCheck": true to my tsconfig.json removed the compiler errors. I'm not sure it's a good idea to not type-check against used libraries, though.

{
    "compilerOptions": {
        "skipLibCheck": true
    }
}
Was this page helpful?
0 / 5 - 0 ratings