How do you document JSDoc with mixed parameter type?
Solution 1:
You can use the |
separator to specify multiple types in the method type signature:
/**
* Some method
* @param {Object|string|number} param The parameter.
* @returns {Object|string|number} The modified param.
*/
function doSomething(param) {
return etc..
};
Solution 2:
Google Closure Compiler Docs recommend the following form - which looks official as it is the same as found on usejsdoc.org:
/**
* Some method
* @param {(Object|string|number)} param The parameter.
* @returns {(Object|undefined)} The modified param.
*/
function doSomething(param) {
return etc..
};
To cite the above linked closure compiler docs:
Note the parentheses, which are required.