28
votes

I've an ES6 project in WebStorm which obviously sometimes uses some built-in objects like Math or JSON.

Both HTML / ECMAScript 5 and ECMAScript 6 are enabled in "Settings/(...)/JavaScript/Libraries", yet WebStorm still suggests that Math and JSON are missing imports.

When I create an empty new project it works fine. I also noticed that when selecting JSON in such new project and pressing CTRL+B, WebStorm shows definitions from its internal library.

To the contrary in my main project it shows some TypeScript ones from completely unrelated part of the project. If I move the folder with typescript outside the project it seems to work.

Nota bene, the file I have errors in is not written in TypeScript, does not include anything TypeScript related and is not processed with TypeScript in any way. It is only processed with ES6 to ES5 transpiler.

3
Can't recreate. Please try invalidating caches (File/Invalidate caches, Restart) - does the problem persist? if yes, please try composing a sample project that shows up the issue. Note that you can suppress 'Missing import statement' inspection for these statement - lena
@lena I got the same issue, clearing the cache and restart won't help. (i'm on pycharm) - Robert Brax
It's been 5 month and there is still no answer or fix for this. It's pretty annoying. - vladblindu
@lena, is it possinle to at least find the file/direcotry which triggers the missing import behavior on the project? - jaboja

3 Answers

44
votes

This worked for me:

  • Navigate Settings -> Languages & Frameworks -> Node.js and NPM
  • Click Enable for Node.js Core library under Coding Assistance section
  • Click Apply

I restarted WebStorm and warnings went away.

3
votes

Marking the directory with TypeScript based subproject as excluded (right click → “Mark Directory as” → “Excluded”) solves the problem without need to physically remove it from the project.

0
votes

I had the same issue and I found the solution:
For me it was because I had a ECMA 5.1 project with a subfolder in ECMA 6.
Just invert it: Set all ECMA 5.1 files in ECMA 5.1 and set the main project version to ECMA 6.