I have the following class constructor:
class Logger {
/** @constructs
@param { number } minlevel Minimal level to shown log
@param { function } callback to really do the process
*/
constructor( minlevel, callback ) {
if( minlevel instanceof Logger ) {
// Duplicar el objeto.
this.$callback = minlevel.$callback;
if( typeof( callback ) === 'number' ) {
this.$minLevel = callback;
} else {
this.$minLevel = minlevel.$minLevel;
}
} else {
// Nueva instancia.
if( typeof( callback ) != 'function' ) throw TypeError( );
this.$minLevel = minlevel;
this.$callback = callback;
}
}
}
This constructor has 2 overloads (use cases, with different types of arguments and different results). Expressed in TypeScript (to clarify), it would be like this:
-
constructor( other : Logger, minlevel? : number )
Used to clone an instance; generates a copy, with an optional
minlevel
argument. -
constructor( minlevel : number, callback : Function )
Used to create a new instance without relying on any other.
I would like to document both overloads using JSDoc , but I can not find the correct way. As it is now, it generates
which is what I expect for the second overload .
How can I document functions / constructors / getters / setters overloaded using JSDoc?