I'm in need of writing JsDoc for an abstract method in the parent class so that it applies to all its sub-classes.
Here's a basic example similar to what I'm dealing with:
class Shape {
/** Performs some complex functionality.
* @param {number} myNumber a valid number.
* @param {boolean} myBoolean a boolean flag.
* @param {string} myString some string data.
* @returns {string} important output.
*/
doStuff(myNumber, myBoolean, myString) {}
}
The doStuff
method isn't implemented as each subclass has its own implementation based on the same parameters and return type.
class Triangle extends Shape {
doStuff(myNumber, myBoolean, myString) {
return myBoolean ? myNumber.toString() : myString;
}
}
In the provided screenshot, it's apparent that the text portion of the documentation is inherited, but the parameter types and return type are missing. How can I inherit the types correctly? I've tried using various tags such as @inheritdoc
, @abstract
, @extends
, @override
, and @link
without success.
https://i.sstatic.net/jiZRy.png
Please keep in mind that this example is greatly simplified; in my actual code, the documentation block spans over 20 lines, and manually copying it to numerous subclasses isn't practical due to maintenance concerns.