1

I have an angular2 CLI project.

Two days ago, because my Webstorm IDE complained about new Promise and string[].map could not been resolved, i forcefully installed es6-promise inside node_modules/@types folder using:

npm install @types/es6-promise --save

You can find the related question here: TypeScript complaining that array.map is not present on array of type string[]

Webstorm IDE finally worked as expected, no red underlined files , but today when I reloaded the app in the browser, I got this 6 errors:

enter image description here

I would say that the message error is pretty straight forward. The newly installed types in index.d.ts file from @types folder, are colliding with the ones form node_module/typescript - the main module of typescript compiler - which Angular2 CLI created and is using by default.

Essentially: declarations like: "declare class Promise<T> etc.." inside @types/es6-promise/index.d.ts are the same with the ones in typescript/lib/lib.es2015.promise.d.ts.

Ouestion: how to get around this? What code is needed to eliminate this conflict?

As of now (2 October 2016) - if you do a fresh ng init - in Webstorm IDE - you can't have let myPromise = new Promise() or any other es6 operators - without the file being marked with an error. If you install stuff in @types on your own - you get this duplicate identifier error..

Not being presumptuous here, but I'm pretty sure it's not only me - just created a fresh ng2CLI project. Can't get around this. Can anyone confirm that this is happening on their end? I lost half a day trying to solve this nonsense. Any thoughts on this matter are highly appreciated:) Thanks.

Community
  • 1
  • 1
AIon
  • 12,521
  • 10
  • 47
  • 73
  • Check your TS config. if you have `es6` in `lib` section (and you probably should), you don't need `@types/es6-promise` or any other ES6 types. – Estus Flask Oct 02 '16 at 21:50
  • yep i know, "lib": ["es6","dom"], and is not working. I just find out that i can't use Promises in my angular 2 project. Crazy! – AIon Oct 02 '16 at 21:53
  • Not sure what's going on, but this is a problem of Webstorm in the first place, and adding @types/es6-promise is a mistake here (btw, the link for related question above isn't related at all). I would suggest to step back, remove @types/es6-promise and re-ask the question according to Webstorm output. A reproducible repo that includes A2 project and .idea folder would help. – Estus Flask Oct 02 '16 at 22:12
  • @estus, yes man you are right! turns out that was a webstorm problem also - you can see here: http://stackoverflow.com/questions/35660498/angular-2-cant-find-promise-map-set-and-iterator – AIon Oct 02 '16 at 22:42
  • Thanks, nice to know that CLI doesn't play well with Jetbrains products (used non-CLI projects with no problems). – Estus Flask Oct 02 '16 at 23:32
  • I'm using the CLI fine with Webstorm, no problems at all. – Ben Richards Feb 04 '17 at 02:50

0 Answers0