Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to document deconstructed parameters with JsDoc

How do I document a function parameter that gets deconstructed in function arguments?

/**
 * Function deconstructs argument and do stuff.
 * @param {} *** what should i do here? ***
 */
function someFunction({ key1, key2, key3 }) {
    // do function stuffs
}
like image 337
Pulasthi Bandara Avatar asked Aug 21 '17 02:08

Pulasthi Bandara


1 Answers

From the @param wiki page:

If a parameter is destructured without an explicit name, you can give the object an appropriate one and document its properties.

Documenting a destructuring parameter

/**
 * Assign the project to an employee.
 * @param {Object} employee - The employee who is responsible for the project.
 * @param {string} employee.name - The name of the employee.
 * @param {string} employee.department - The employee's department.
 */
Project.prototype.assign = function({ name, department }) {
    // ...
};
like image 63
Felix Kling Avatar answered Oct 16 '22 21:10

Felix Kling