How to describe arguments to a destroyed object in JSDoc

If I have a JavaScript function that takes an object as a parameter, I can describe the expected properties of the object using JSDoc as follows:

/** * @param bar * @param bar.baz {number} * @param bar.qux {number} */ function foo(bar) { return bar.baz + bar.qux; } 

How can I describe these properties if I define my function with ECMAScript 6 destructuring without giving the real parameter object a name at all?

 const foo = ({ baz, qux }) => baz + qux; 
+5
source share
1 answer

It turns out that JSDoc supports destruction by creating a placeholder. The official documentation is missing.

https://github.com/jsdoc3/jsdoc/issues/987

 /** * @param {Object} param - this is object param * @param {number} param.baz - this is property param * @param {number} param.qux - this is property param */ const foo = ({ baz, qux }) => baz + qux; 
+6
source

Source: https://habr.com/ru/post/1269008/


All Articles