I don't if the title properly expressed what I am trying to do. But I have the following function:
/**
* @param {any} param1
* How to describe the second parameter??
* @returns {Object}
*/
function doSomething (param1, { property1 = null, property2 = null }){
// do stuff
return something
}
As questioned in the comment, using JSDocs, how would I describe the second parameter?
Use square brackets [] to indicate optional parameters.
Like so:
/**
* @param {any} param1
* @param {Object} somethingWithProps - Some description
* @param {string} [somethingWithProps.property1] - First property
* @param {string} [somethingWithProps.property2] - Second property
* @returns {Object}
*/
function doSomething (param1, { property1 = null, property2 = null }){
// do stuff
return something
}
From the docs: Optional parameters and Documenting a destructuring parameter
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