tsd-jsdoc icon indicating copy to clipboard operation
tsd-jsdoc copied to clipboard

Error message for private subclass of public superclass

Open willeastcott opened this issue 5 years ago • 3 comments

The following JavaScript:

/**
 * @constructor
 * @name Animal
 * @classdesc An animal.
 * @description Creates a new animal.
 */
function Animal() {
    this.x = 0;
    this.y = 0;
}

/**
 * @function
 * @name Animal#move
 * @description Move the animal to the specified location.
 * @param {Number} x - X-coordinate.
 * @param {Number} y - Y-coordinate.
 */
Animal.prototype.move = function (x, y) {
    this.x = x;
    this.y = y;
}

/**
 * @private
 * @constructor
 * @name Dog
 * @extends Animal
 * @classdesc A dog.
 * @description Creates a new dog.
 */
function Dog() {}

Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;

/**
 * @private
 * @function
 * @name Dog#bark
 * @description The dog barks.
 */
Dog.prototype.bark = function () {
    console.log('Woof!');
}

...generates this message:

[TSD-JSDoc] Failed to find parent of doclet 'Dog#move' using memberof 'Dog', this is likely due to invalid JSDoc.

This bug is currently afflicting the PlayCanvas engine. See forum post.

willeastcott avatar Nov 18 '19 09:11 willeastcott

Look like this is because the move function is not marked private by jsdoc so we try to document it. When we try to lookup where it belongs we fail to find the Dog class because it is private.

The implementation should probably still track private objects so we can tell the difference between an unknown symbol and an existing, but private, symbol. In the later case we can skip the move/bark functions and not output the warning.

englercj avatar Dec 01 '19 17:12 englercj

This issue is fixed now by merged PR #126 in latest release

aidinabedi avatar Apr 13 '20 19:04 aidinabedi

It looks like #126 did not fix this; at the very least, there should be a test case for this specific problem (@private class, with a @memberof tag on a prototype function) and the tests added for that PR definitely do not include one.

thw0rted avatar May 28 '20 11:05 thw0rted