Currently, the best approach with jsdoc 3 involves using the @also
tag to signify that a function has multiple signatures. It is important to clearly outline in the description when each signature applies.
/**
* When the <code>timeframe</code> parameter is not 3...
*
* @param {number} timeframe Can be 0, 1, 2.
* @param {number} [since] blah.
* @param {number} [until] blah.
*
* @also
*
* When the <code>timeframe</code> is 3, then...
*
* @param {number} timeframe Set to 3.
*/
function getTimeframe(timeframe, since, until) {
}
This will define two distinct signatures for the getTimeframe
function.
(Please note: I opt for using number
over Number
in cases like this because 1 instanceof Number
yields false
, while typeof 1
is "number"
and typeof Number(1)
is also "number"
.)