如何使用JsDoc记录解构参数 [英] How to document deconstructed parameters with JsDoc
本文介绍了如何使用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
}
推荐答案
来自 @param wiki page :
如果参数在没有显式的情况下被解构name,你可以给对象一个合适的对象并记录它的属性。
If a parameter is destructured without an explicit name, you can give the object an appropriate one and document its properties.
记录一个解构参数
/**
* 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 }) {
// ...
};
这篇关于如何使用JsDoc记录解构参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文