Does WebStorm support jsDoc type hints for jQuery autocompletion
We have an app that needs to support multiple possible jQuery versions. Therefore we assign the jQuery version we need to a variable, i.e.:
myjQuery = jQuery;
Then we have modules structured like this to which myjQuery is passed as an argument to be referenced as $:
/**
*
* @param {jQuery} $
*/
myApp.myModule = function ($,document,window,undefined) {
var myfunc1 = function myfunc1(arg1) {
}
function myfunc2 (arg1, arg2) {
}
function privatefunc() {
}
var myprivate = function myprivate() {
}
$('#test') // <--- Autocomplete should recognize this is a jQuery object and list its methods first
return {
myfunc1:myfunc1,
myfunc2:myfunc2,
newname:myfunc1,
publicfunc: function(param) {
}
}
}(myjQuery,document,window);
If we pass jQuery to the module function above, autocomplete works but with myjQuery it does not. Komodo is capable of looking at that jsDoc @param hint that $ is jQuery and autocomplete works there. But it doesn't appear to be the case in Webstorm 4.0.2.
Is there some other trick to make autocomplete for jQuery work in the above scenario?
Unrelated, if you look at the above code there are several ways to declare private and public functions, some of which are not properly shown in the Structure panel. Specifically, myprivate() isn't shown with a lock, it's shown exact same way as publicfunc and newname is shown as an object, not a method at all and doesn't show arguments.
请先登录再写评论。
Hi Alex,
Thanks for feedback, this is a bug which will be fixed.
As for now, I can suggest slightly modify your code so it looks like:
It appears both issues (type recognition inside a self-executing function expression and module pattern private vs public methods and parameter display in Structure panel) still exist in version 5.0.
Sorry, type recognition and some cases on private and public icons will be fixed in next 5.0.x release. Please, next time create a request in our tracker to be more confident that it would not be lost:).