javascript 如何使用JsDoc记录解构的参数

avkwfej4  于 2022-12-21  发布在  Java
关注(0)|答案(1)|浏览(156)

如何记录在函数实参中被解构的函数形参?

/**
 * Function deconstructs argument and do stuff.
 * @param {} *** what should i do here? ***
 */
function someFunction({ key1, key2, key3 }) {
    // do function stuffs
}
o4hqfura

o4hqfura1#

从@param Wiki页面:
如果参数在没有显式名称的情况下被破坏结构,则可以为对象指定一个适当的名称并记录其属性。

记录结构化参数

/**
 * 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 }) {
    // ...
};

相关问题