Search code examples
javascriptnode.jsintellij-ideajsdoccommonjs

How to jsDoc node module.exports object methods in Intellij?


I'm trying to get intellij to recognize my jsdocs for an module.exports object. It keeps giving me an Inferred Type: Function for the Crtl + Q document preview.

Edit: Tried adding @name module.exports.nameToUpperCase suggestion from @dez

'use strict';

/**
 * Uppercases supplied name.
 * @name module.exports.nameToUpperCase
 * @param name {string} The name to uppercase
 * @returns {string} Uppercase version of the supplied name
 */
var nameToUpperCase = function (name) {
    return name.toUpperCase();
};

module.exports = {
    nameToUpperCase: nameToUpperCase
};   

I also checked out the jsdocs, but it seems that the only example is to do:

'use strict';

/**
 * Uppercases supplied name.
 * @param name {string} The name to uppercase
 * @returns {string} Uppercase version of the supplied name
 */
module.exports.nameToUpperCase = function (name) {
    return name.toUpperCase();
};

However I am trying to have it appear as the first method since my exports object has many methods.


Solution

  • So I send in a ticket to intellij yesterday, same day I made the question post. Today they replied with that I should download the idea 15, currently in beta, as they added in the feature to my request... I tried it, and it works... Wicked fast response and feature built. Intellij ftw.

    'use strict';
    
    /**
     * Uppercases supplied name.
     * @name module.exports.nameToUpperCase
     * @param name {string} The name to uppercase
     * @returns {string} Uppercase version of the supplied name
     */
    var nameToUpperCase = function (name) {
        return name.toUpperCase();
    };
    
    module.exports = {
        nameToUpperCase: nameToUpperCase
    }; 
    

    Now works as expected!