PhpStorm complains that NodeJS predefined objects such as JSON, Error, etc. are unresolved
Using the latest PhpStorm (2018.2)
Tried enabling "Coding assistance for Node.js"
Specified the interpreter in settings.
Tried enabling HTML and Node.js Core JavaScript libraries in settings.
Still have JSON, Error etc. as unresolved variables (red color).
Googled a lot but didn't find any solution. Any ideas on how to fix that?
Please sign in to leave a comment.
Did you enable it at File | Settings | Languages & Frameworks | Node.js and NPM ?
Yes, of course.
I've enabled the checkbox "Coding assistance for Node.js" and specified the path to the interpreter. It is correctly detected as 10.0
Please can you provide screenshots of the errors? hover over the highlighted object to see a tooltip and take a screenshot
weird... Both types are resolved to the corresponding definitions in plugins\JavaScriptLanguage\jsLanguageServicesImpl\external\lib.es5.d.ts predefined library. It's available for all projects, even if no libraries are enabled in Settings | Languages & Frameworks | JavaScript | Libraries
Can you check if the issue persists after caches invalidation?
Yes I've tried to invalidate caches & restart but the issue does persist :(
can you recreate it in a new project?
Yes. Tried creating a new project and pasting the code from the screenshots above with the same validation errors.
please can you provide this new project (including .idea folder) plus your settings (~\.PhpStorm2018.1\config folder)?
idea.log (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) might be also helpful
http://37.48.93.204/phpstorm_issue_project.zip
http://37.48.93.204/phpstorm_issue_config.zip
http://37.48.93.204/phpstorm_issue_log.zip
Thanks! Found the issue: you have re-mapped *.ts extension from Typescript file type to XML:
but all Javascript predefined libraries are stored as Typescript d.ts files; if they can't be parsed because these files are not treated as Typescript anymore, functions definitions are not available and can't be resolved
Please assign *.ts pattern back to TypeScript file type
Oh thank you so much!
I think it would be great to have some kind of warning if the user attempts to remap a .ts extension explaining the possible consequences.