如何使用JsDoc记录解构参数

时间:2017-08-21 02:29:31

标签: javascript ecmascript-6 jsdoc

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

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

1 个答案:

答案 0 :(得分:13)

来自@param wiki page

  

如果参数在没有显式名称的情况下被解构,您可以为对象提供一个合适的参数并记录其属性。

     

记录解构参数

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