Using external javascript libraries in phpstorm

PHPStorm 7.0

I have a project using external Javascript libraries. The library sources are located on my disk but outside of the project root. They are available from my localhost server. The libraries files are included in the Project Settings->Javasript->Libraries. During code editing, I get code hints for those libraries, so PHPStorm knows them.

However, there are two problems:

1. In main.js file, properties from those libraries are underlined as "Unresolved variable" (strange.. these are the same properties that get code hints during typing)
2. In index.html file where the libraries are included using <script> tag, they are colored and marked as "There is no locally stored library for the HTTP link".

How to tell PHPStorm where those libraries are to get rid of those problems?

3 comments
Comment actions Permalink

1. please can you provide file(s)/code snippets that show up the issue?
2. that's normal - WebStorm can't match the CDN link to your library files available locally. Either agree to download the library (via Alt+Enter), or just ignore the warnings

0
Comment actions Permalink

This is how I add libraries to settings:



The javascript code is:

jQuery(document).ready(function() {
  var c = createjs;
  console.log(c.EaselJS.version);
  var stage = new c.Stage('main');
//......
});

As you can see. PHPStorm gives the hint while typing "c.EaselJS":



But after the typing is finished, it is underlined:



The browser console shows the version correctly.

0
Comment actions Permalink

I can suggest using typescript stubs (https://github.com/borisyankov/DefinitelyTyped/blob/master/easeljs/easeljs.d.ts) as a library:
disable the library you have configured and use Download... button in Languages&frameworks/javaScript/Libraries to download and install easeljs stub

Please follow https://youtrack.jetbrains.com/issue/WEB-12127 for updates

0

Please sign in to leave a comment.