How to document an array of objects in JSDOC

I have a function with an array of objects as a parameter and would like to describe this parameter (including the properties of the objects in the array) using JSDOC, as in this example:

/**
 * @param {Array.<Object>} filter - array of filter objects
 * @param ...
 */
function doSomething(filter) {
}

where the filter looks something like this:

filter = [
   {id: 'session', value: 1},
   {id: 'name', value: 'john'}
]

How can I document the properties idand valuein jsdoc3?

+4
source share
1 answer

like this:

/**
 * @param {Object[]} filter - a list of literal filter objects
 * @param {string} filter[].id -  id to filter against...
 * @param {string|number} filter[].value - value to filter for...
 */
function doSomething(filter) {
    // do stuff
}

taken from http://usejsdoc.org/tags-param.html

+11
source

All Articles