Skip to content

Instantly share code, notes, and snippets.

@sallar
Created November 30, 2015 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sallar/fb2bae29bd41d83f211b to your computer and use it in GitHub Desktop.
Save sallar/fb2bae29bd41d83f211b to your computer and use it in GitHub Desktop.
WebStorm AMD/JSDoc Problem

OK, So imagine you have this module which accepts another module as a parameter to one of it’s methods:

define("modules/module2", [], function() {

    return {
        /**
         * @param {module:myNamespace/module1} SomeModule
         */
        somethingElse: function(SomeModule) {
            var instance = new SomeModule();
            SomeModule.sayHello();
        }
    }

});

Notice that @param {module:myNamespace/module1} SomeModule is JSDoc’s recommended way of annotating module dependencies. But this is who it shows up in Webstorm:

Webstorm doesn’t recognize the module. But if I change the param definition to:

/**
 * @param SomeModule {@type module:myNamespace/module1}
 */

Webstorm starts recognizing it and offers autocomplete, etc. There is two changes: Parameter name is first, then after { I added @type to make sure webstorm knows this is a module. But this is not standard in JSDoc and I don’t want to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment