WebStorm : explain 'Unresolved type Promise' highlight in code

rather new to JS and very new to WebStorm, crafting a cordova multi-device app, i get the following in one of my .js modules

Screen Shot 2015-06-19 at 4.01.07 PM.png

However, this works fine in all devices, simulators and browsers i can run on at the moment. Why am I getting this warning highlight, what configuration am i missing?? I would prefer keep the inspection than nuke it (because i am very likely to need it for my own stuff :) ),  but configure my project properly to not have 'false negatives' like this.

regards,

-- Yves

ws 10.0.4, osx 10.10.2

2

Obviously not since i am getting this highlight.

Newbie JS question here : it still works everywhere i deploy this (ios sim, ios device(s), android sim, android device(s), chrome,safari,and firefox browser). So somehow, that Promise is implemented everywhere. I verified in my deployment bundles, there is absolutely nothing that i deploy which implements a Promise.  All i have in my libraries right now are HTML and HTML5 Ecma5. I thought that was part of Ecma5 since it works everywhere!

How would i go about finding where it is defined (since it works) and adding that to the list of libraries of my project ?

0

OK , figured it out. Turns out Promise is 'standard' Ecma6. Just check it in the prefs>Languages&Frameworks->JavaScript->Libraries  as shown here

Screen Shot 2015-06-21 at 11.51.48 AM.png

cautions : this 'defines< all of ECMAScript 6 and some of it may not  be 'in the box' when you deploy. It just happens Promise is.

1

That did not worked for me :(

0

What didn't work for you?


0

The solution for me was to add a "promise" library in the settings:

1) go to File>Settings>Language & Frameworks>Javascript>Libraries 

2) Click Download.

3) In the dialog, select TypeScript community stubs from the dropdown.

4) Find "promise" on the list, select it and click on Download ans Install.

IntelliJ will use the TypeScript definition to inspect the JavaScript code.

(PyCharm 2016.2 / Ubuntu 16.04)

 

1
Avatar
Permanently deleted user

Thanks Pablo that worked!

0

Select the Javascript language version in the settings:

0

@Pablo, there is not a single promise library but many (promise-dag, promise-polyfill, etc..) . Which one does the trick ?

0
Avatar
Permanently deleted user

Same problem for me. None of the previous resolved the error. 

WebStrorm version: 2018.1

Notice that Promise is not highlighted when I use "new Promise" but is highlighted in all other cases (e.g. if I write "Promise.resolve()"

It is driving me crazy!

0

I'm seeing this in 2018.1.1 was well.

0

Promise typings are built-in, but any library that exports `Promise` may result in such issues, as WebStorm will use this module instead of a native Promise object. Related tickets: https://youtrack.jetbrains.com/issue/WEB-31084, https://youtrack.jetbrains.com/issue/WEB-30297

0
Avatar
Permanently deleted user

It's happening in IntelliJ too.  ECMA Script 6 selected and all other things working (like async / await) but Promise shows as unresolved unless you explicitly import a promise library.  Before doing that I had no promise libraries included as I'm targeting latest browsers.

It is possible that something I import includes a promise library - but it would mean not being able to use standard NPM modules, which is clearly not at option.

With a library:

 

0

请先登录再写评论。