Search code examples
javascriptjqueryintellij-ideacode-completion

Javascript library load order in IntelliJ causing incorrect function signatures


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 code, 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)


Solution

  • Elena Pogorelova of IntelliJ helped me out with this one. Answer is to use jquery Typescript community stubs for type resolving instead (https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000555830/comments/115000461584). Though that currently brings up other issues, they are working on it.