Skip to content Skip to sidebar Skip to footer

How To Describe Destructured Object Arguments In Jsdoc

If I have a JavaScript function taking an object as a parameter, I can describe expected properties of the object with JSDoc like this: /** * @param bar * @param bar.baz {number}

Solution 1:

It turns out JSDoc does support destructing via making up a placeholder name. It is lacking in official documentation.

http://usejsdoc.org/tags-param.html#parameters-with-properties

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

Solution 2:

I had the same question too. Now I am using Visual Code Studi, its plugin does something like this (this is suitable for me):

/**
 * @param  {} {a
 * @param  {} b
 * @param  {} c}
 * @param  {} {d}
 */constaaa = ({a,b,c},{d}) => {

}

Post a Comment for "How To Describe Destructured Object Arguments In Jsdoc"