【问题标题】:How to document deconstructed parameters with JsDoc如何使用 JsDoc 记录解构参数
【发布时间】:2018-01-29 00:38:18
【问题描述】:

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

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

【问题讨论】:

标签: javascript ecmascript-6 jsdoc


【解决方案1】:

来自@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 }) {
    // ...
};

【讨论】:

  • 你如何记录function (arg1, arg2, { prop1, prop2 })
  • 您在第三个参数之前为arg1arg2 添加@param 标签。
猜你喜欢
  • 1970-01-01
  • 2020-05-21
  • 1970-01-01
  • 2013-05-30
  • 2022-01-16
  • 2021-11-03
  • 2015-02-10
  • 2013-12-09
  • 2013-05-22
相关资源
最近更新 更多