menaka
menaka

Reputation: 1068

Webstorm says Promise is an unresolved type

Using WebStorm 10.0

I am currently learning Node Js and installing all of the component it need to work . So i chose to used Jest to test my work, i already installed Jest to my frameworks and languages inside the WebStorm but its keeps showing Promise as unresolved type how do i fix it in WebStorm?

unresolved type

enter image description here

Upvotes: 9

Views: 5981

Answers (3)

Kyle Phillips
Kyle Phillips

Reputation: 11

Also, check your tsconfig.json. Either add es6 or es2015.promise to your tsconfig.lib[]

{
  "compilerOptions": {
    ...
    "lib": [
      "es2015.promise"
    ]
  }
}

Upvotes: 1

Floris
Floris

Reputation: 3127

I used the vanilla Javascript Promise and also got an unresolved type error message in phpStorm.

I fixed it by downloading this file: https://raw.githubusercontent.com/Microsoft/TypeScript/master/src/lib/es2015.promise.d.ts

And imported it into phpStorm like this:

Go to Settings | Languages & Frameworks | JavaScript | Libraries. Then click on Add type in a name, choose Global (if you like), click on the + symbol and choose Add file. Select es2015.promise.d.ts from your drive and click OK two times.

The underline disappears and I got intellisense now!

Upvotes: 0

lena
lena

Reputation: 93738

Promise type is not a part of Jest module; please try enabling 'ECMAScript 6' library for your project in Settings | Languages & Frameworks | JavaScript | Libraries. If it's not available in your version (it is there since WebStorm 11), try downloading typescript stubs for 'promise' library (promise.d.ts)

Upvotes: 13

Related Questions