简体   繁体   中英

Describing an array of objects in JsDoc

I've got a function which takes an array of objects.
Looks like this.

myAwesomeFunction([
    {
        name: 'someName',
        next: false,
        test: 'test'
    },
    {
        name: 'nameTwo',
        next: true
    }
]);

So far my JSDOC looks like this

/**
 * My description
 * @param {Array.<Object>}
 */

But how can I describe the object properties, types and descriptions and if they are optional of the object?

Thank you.

JSDoc @param documentation

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

Using typedef

/**
 * @typedef AwesomeObject
 * @type {Object}
 * @property {string} name
 * @property {boolean} next
 * @property {string} test
 */

/**
 * @param {Array.<AwesomeObject>} awesomeObjects Awesome objects.
 */
myAwesomeFunction(awesomeObjects) { ... }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM