I have a function documented with JSDoc which then becomes part of an object literal.
How can I forward the documentation for the function to the object literal, and thus make it available to an external scope (such as outside an outer function, or a different module)?
I could write the JSDoc on the object literal itself, but I don’t want to move the JSDoc from the function.
<code>const { printRandom } = (() => {
/**
* Prints a random number
*/
const printRandom = () => console.log(Math.random())
return {
printRandom
}
})()
</code>
<code>const { printRandom } = (() => {
/**
* Prints a random number
*/
const printRandom = () => console.log(Math.random())
return {
printRandom
}
})()
</code>
const { printRandom } = (() => {
/**
* Prints a random number
*/
const printRandom = () => console.log(Math.random())
return {
printRandom
}
})()
In other words, in VSCode when hovering over the printRandom
variable in the outer scope, I would like to see the JSDoc.