How to document Array
return value (and parameters) in JSDoc when array elements can be either of the following:
String
, Array
).If you're looking for how to document the type of objects in an array, you want something like this:
/** * @param {String[]} aliases */
Here inside curly-braces the String[]
is the parameter type: type String
as array []
.
See also jsdoc-toolkit, archived wiki page about @Param tag, Parameter Type Information:
Parameter Type Information
Use curly-braces around the expected type of the parameter to document this information.
/** * @param {String} userName */ function logIn(userName) { // ... }
Use a pipe symbol to document that multiple types are permitted.
/** * @param {String|Number} product */
Use the [] notation after a type to indicate an array of those types.
/** * @param {String[]} aliases */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With