Reputation: 31
/**
* Returns the sum of all numbers passed to the function.
* @example
* sum([1,2,3])
* //returns 6
* sum(1,2,3)
* //returns 6
* @param {number[]|...number} params - ???
*/
function sum(params) {
var args = params instanceof Array ? params : arguments;
for (var i = 0, sum = 0; i < args.length; i++)
sum += args[i];
return sum;
}
'params' can be a array or repeatable numbers
but "@param {number[]|...number}" not working.
Written document output have no difference with "@param {number[]|number}"
Which is the best way to indicate on this situation?
Upvotes: 2
Views: 1244
Reputation: 2439
The trick is using parenthesis. I used the following at it works.
* @param {...(object|string)} col - An optional set of columns to select.
Updated for your parameter names, this should work:
* @param {...(number[]|number)} params - ???
I can't find any documentation for the parenthesis, but under JSDoc 3.4.2 that does the trick.
This comment:
/**
* Select columns manually.
* @param {...(object|string)} col - An optional set of columns to select.
* Each argument can either be a fully-qualified column name in the form
* <table-alias>.<column-name>, or an object with the following
* properties below. If no columns are specified, then all columns are
* selected.
* @param {string} col.column - The fully-qualified column name.
* @param {string} col.mapTo - The name of the property that the column
* should be mapped to in the resulting normalized object. @param
* @param {function} col.convert - A converter function that takes a single value
* from the database and transforms it. For example, a function that
* converts a bit from the database to a boolean value.
* @return {this}
*/
Yields this documentation:
Hope that helps!
Upvotes: 1