Angular-cli: (beta.11-webpack) Promise - Corresponding file is not included in tsconfig.json

Created on 3 Aug 2016  路  24Comments  路  Source: angular/angular-cli

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    ubuntu 16.04
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack
node: 5.11.1
os: linux x64
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
the app was build with angular-cli@beta-10. I followed upgrade instructions and Promises no longer worked, along with styles. 
  1. The log given by the failure. Normally this include a stack trace and some
    more information.
No errors client side. Just in webstorm.
  1. Mention any other details that might be useful.
ran `npm i @types/es6-promise` and tried adding "es6-promise" to "types":["jasmine"] array and that didn't work. Makes my app unusable.

Thanks! We'll be in touch soon.

UPDATE
Promises still compile and work, but it shows all the errors in webstorm. Not sure if I should just suppress statements with Promise types and .then() statements or not.

RFC / discussion / question

Most helpful comment

I had this problem in quite a few projects with IntelliJ. Here is how to get rid of it:

  1. Install Typescript 2.X
  2. Go to Preferences > Languages and Frameworks > Typescript.
  3. set Typescript version custom, navigate to /usr/local/lib/node_modules/typescript/lib (if you use brew, it's somewhere else)
  4. check "Use Typescript Service (Experimental)"

you'll have to do this for every project. Good news is, this should use Typescripts own service, meaning this should work for every Typescript version in the future. (Until someone breaks it of course)

screen shot 2016-10-23 at 02 06 47

All 24 comments

After doing the same thing over again a few times I managed to get it to work.

npm i @types/es6-promise
then added es6-promise to types in tsconfig.json

for some reason those steps didn't work the first time, now it does.

Now i get this after ng build -prod

ERROR in [default] /home/eric/Documents/www/ng2/olweg/node_modules/@types/es6-promise/index.d.ts:11:14 
Duplicate identifier 'Promise'.

ERROR in [default] /home/eric/Documents/www/ng2/olweg/node_modules/@types/es6-promise/index.d.ts:42:18 
Duplicate identifier 'Promise'.

ERROR in [default] /home/eric/Documents/www/ng2/olweg/node_modules/typescript/lib/lib.es2015.iterable.d.ts:121:10 
Duplicate identifier 'Promise'.

ERROR in [default] /home/eric/Documents/www/ng2/olweg/node_modules/typescript/lib/lib.es2015.promise.d.ts:20:10 
Duplicate identifier 'Promise'.

ERROR in [default] /home/eric/Documents/www/ng2/olweg/node_modules/typescript/lib/lib.es2015.promise.d.ts:187:12 
Duplicate identifier 'Promise'.

ERROR in [default] /home/eric/Documents/www/ng2/olweg/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:164:10 
Duplicate identifier 'Promise'.

tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ],
    "types": [
      "jasmine","es6-promise"
    ]
  }
}

It still compiles and works however. It seems to be complaining about declare class Promise and declare namespace Promise is all I can make of it.

The lib entry on tsconfig takes care of providing Promise to the Typescript compiler.

The problem here is that your editor does not yet support TS2.0 properties such as lib, typeRoots and types I believe. VS Code also has that problem.

It's an editor problem though, not a CLI problem... maybe you can update the version of typescript used in Webstorm. Can't help you much there since I don't use it myself.

I re-updated the cli and used typescript 2.0 libs in my editor. it still gives errors, so ill just suppress them for now.

Having the same issue here. How did you suppress the errors? Is there a permanent solution yet?

I have the same issue, even after update to webstorm 2016.2.2 from 2016.2.1. TypeScript version 1.8 in the "Languages & Frameworks" settings.

You have to update the version of Typescript used in Webstorm to 2.0.0. Check Webstorm documentation on how to do this.

@EugenIvanou @Codermar @eshell I guess Webstorm is pretty similar to Idea, I am using 2016.2 version and I have installed TypeScript 2.0.2 as global package, then I configure Idea to use that version and not the bundled one.

screen shot 2016-09-11 at 10 52 59

I guess all the issues comes from, as pointed out from @filipesilva, the TypeScript version you use. Idea/Webstorm should even mark some issue in the tsconfig.json about some unrecognized properties.

@filipesilva said that lib properties has to provide Promises definition to compiler, indeed from tsconfig schema

"lib": {
  "description": "Specify library file to be included in the compilation. Requires TypeScript version 2.0 or later.",
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "es5",
      "es6",
      "es2015",
      "es7",
      "es2016",
      "es2017",
      "dom",
      "webworker",
      "scripthost",
      "es2015.core",
      "es2015.collection",
      "es2015.generator",
      "es2015.iterable",
      "es2015.promise",
      "es2015.proxy",
      "es2015.reflect",
      "es2015.symbol",
      "es2015.symbol.wellknown",
      "es2016.array.include",
      "es2017.object",
      "es2017.sharedmemory"
    ]
  }
}

I have just generated a project with angular-cli, I had your same issue that disappeared once TypeScript 2.0.2 has been configured, if I install @types/es6-promise I get duplicate identifier error as @eshell.

My current platform version:

angular-cli: 1.0.0-beta.11-webpack.8
node: 5.4.1
os: darwin x64

Under OS X global packages are installed in /usr/local/lib/node_modules.

Hope it helps 馃槈

@blackat how did you do that? I am still getting the error. I have configured the typescript version in the webstorm, what else steps do I need? update the tsconfig file?

@ljieyao Have you tried to remove es6-promise from

"types": [ "jasmine","es6-promise" ]

?

@blackat yes. i did. as follow is my tsconfig

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es5",
      "es6",
      "es2015",
      "es7",
      "es2016",
      "es2017",
      "dom",
      "webworker",
      "scripthost",
      "es2015.core",
      "es2015.collection",
      "es2015.generator",
      "es2015.iterable",
      "es2015.promise",
      "es2015.proxy",
      "es2015.reflect",
      "es2015.symbol",
      "es2015.symbol.wellknown",
      "es2016.array.include",
      "es2017.object",
      "es2017.sharedmemory"
    ],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  },
  "exclude": [
    "node_modules",
    "typings"
  ]
}

@ljieyao sorry man but the list I have posted was related to the tsconfig schema, you don't have to put everything in your tsconfig unless you really need.

My tsconfig.json is

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  }
}

Then please have a look at this answer from Basarat

certain npm modules includes their own definition files

These will get picked up (despite the exclude) if you set your module to commonjs

Hope il helps 馃槈

@blackat unfortunately, I have done as told, yet, it is not working. Any other possibilities?

It worked for me after I've checked the "Enable TypeScript Compiler" and "Use tsconfig.json" to the WebStorm/PyCharm 2016.2.3 settings window @blackat added above.
My tsconfig.json is:

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "types": ["node"],
    "typeRoots": [
      "../node_modules/@types"
    ]
  }
}

i have this problem too,who resolve this and please tell me

I had this problem in quite a few projects with IntelliJ. Here is how to get rid of it:

  1. Install Typescript 2.X
  2. Go to Preferences > Languages and Frameworks > Typescript.
  3. set Typescript version custom, navigate to /usr/local/lib/node_modules/typescript/lib (if you use brew, it's somewhere else)
  4. check "Use Typescript Service (Experimental)"

you'll have to do this for every project. Good news is, this should use Typescripts own service, meaning this should work for every Typescript version in the future. (Until someone breaks it of course)

screen shot 2016-10-23 at 02 06 47

Thank you so much @suau .
After a long time of headaches, this finally worked for me.

Small addition to @suau's comment: you can use node_modules/typescript/lib folder from your project as custom TypeScript version instead, if you have typescript in your devDependencies (which you should have)

Thx @suau, worked for me too with PhpStorm 2016.2.2 (build PS-162.2380.11)

just found that after upgrading to phpstorm 2016.3.2 the error is gone.

I had the same issue in webstorm 2016.2.X. Issue was resolved after updating to 2016.3.X version

Had this issue in WebStorm 2017.1.4, TypeScript 2.4.0, for a simple package called location-origin. I found that the problem was that I needed to add it as a type to tsconfig.json.

Originally, my types were explicit: "types": ["text-encoding"]. I was able to fix it either by:

  • adding the type to the array, ie. "types": ["text-encoding", "location-origin"]
  • or commenting out the explicit types array altogether, so that TypeScript just imported all types implicitly (this has been possible since TypeScript 2.0).

Coming way after the battle but I happened to stumble upon this problem aswell.
Got it fixed by adding

in tsconfig.json

{
    "compilerOptions": {
        ...
        "lib": ["es6"]
    }
}

I'd love to explain what exactly happens here but I fell upon this solution by browsing Webstorm's auto complete suggestions.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rilwans picture rilwans  路  108Comments

zpydee picture zpydee  路  102Comments

slubowsky picture slubowsky  路  107Comments

elvisbegovic picture elvisbegovic  路  100Comments

beeman picture beeman  路  95Comments