PS-121.322: jsdoc question

Hello.

Here's the example of a typical class pattern I use:

/** * @class */ var Class = (function () {      /**       * @private       * @type {Number}       */      var _privateVar;      /**       * @param {Number} value       * @constructor       */      function Class(value) {           _privateVar = value;      }            function privateMethod(){}            Class.prototype.publicMethod = function () {};            return Class; }());



Looks good and behaves good too (as for intellisense)... Except one thing - the constructor. When I type:

var с = new Class(



I expect constructor's parameters' info to appear, but it doesn't! Is there anything wrong in jsdoc comments or maybe something else?

Any suggestion would be way welcome!

Regards, Roman.

3 comments

Hi, Roman. I've created an issue. As a workaround now you can annotate constructor with @name tag, i.e.

/**
     * @param {Number} value
     * @constructor
     * @name Class
     */
    function Class(value) {
        _privateVar = value;
    }


Regards,
Konstantin.
0

Wow!!! Thank you so much!!! It works!!!

PS: Issue voted

0

I was kind of overoptimistic with my "Wow" in my last reply. :(
The tag @name turned out to be not doing the trick in case of multiple parameters constructor. From all of the parameters only the second one(?!) is being displayed as an autocomplete proposal.

In example let's say I've got the Color class with the constructor that looks like this:

/** * @constructor * @param {Number} red * @param {Number} green * @param {Number} blue * @param {Number} [alpha] * @name Color */
function Color(red, green, blue, alpha) {
     .....
}


then when I start to type its instaniation I see:

new Color(<[Number] green>



Very weird, isn't it?!

0

Please sign in to leave a comment.