Javascript library load order problems
I'm working on a javascript web project that includes no extra libraries or frameworks but jQuery.
I created a project as "Static Web".
In "Settings > Languages & Frameworks > JavaScript > Libraries" i added and enabled jquery, and I can confirm it works.
"HTML" is also enabled.
However, inside my document, on $('...').insertBefore(...) it uses the definition from the "HTML" module "DOMCore.js" instead of jQuery.js. Because of this, its giving incorrect warnings about incorrect function arguments.
Is there a way to tell IntelliJ to consider the jQuery library before the HTML library? If not, why is IntelliJ not remembering the type of a jQuery object when it is declared?
Just for clarity sake, this isn't on just .insertBefore(). It also happens on other functions like .find() (which uses EcmaScript6.js>Array.prototype.find)
Please sign in to leave a comment.
The problem is that WebStorm can't resolve JQuery insertBefore() definition because it's created dynamically in JQuery code:
So the same-named DOM function is resolved instead
You can try using jquery Typescript community stubs for type resolving: in Settings | Languages & Frameworks | JavaScript | Libraries, press Download..., choose TypeScript Community Stubs, select 'jquery' from the list
Shouldn't importing the API documentation fix that though?
don't understand what you meant to say, sorry
If I remove the "HTML" library, it has the correct jQuery function definitions. It is able to parse them b/c the library has Documentation `Settings > Languages & Frameworks > JavaScript > Libraries > jQuery > Documentation URLs`. So it isn't a function definition parsing problem, but an ordering problem.
When HTML library is disabled, WebStorm matches method by name only. Such matching has low priority, that's why method is only resolved to
when no better matches are found