我有一个带有一系列物体的功能 看起来像这样。
myAwesomeFunction([
{
name: 'someName',
next: false,
test: 'test'
},
{
name: 'nameTwo',
next: true
}
]);
到目前为止,我的JSDOC看起来像这样
/**
* My description
* @param {Array.<Object>}
*/
但是如何描述对象属性,类型和描述以及它们是否是对象的可选项?
谢谢。
答案 0 :(得分:11)
/**
* Assign the project to a list of employees.
* @param {Object[]} employees - The employees who are responsible for the project.
* @param {string} employees[].name - The name of an employee.
* @param {string} employees[].department - The employee's department.
*/
Project.prototype.assign = function(employees) {
// ...
};
/**
答案 1 :(得分:2)
/**
* @typedef AwesomeObject
* @type {Object}
* @property {string} name
* @property {boolean} next
* @property {string} test
*/
/**
* @param {Array.<AwesomeObject>} awesomeObjects Awesome objects.
*/
myAwesomeFunction(awesomeObjects) { ... }