Search code examples
javascriptarraysjsdocmaxlengthspecifications

jsDoc - how to specify array length


In jsDoc I can specify my array parameters and members like this:

/**
 * @constructor
 * @param {Array.<string>} myArray
 */
function someFunction( myArray ){

    this.firstArray = myArray;

    /** @member {Array.<float>} */
    this.secondArray = [];

}

Is there also a way to specify the length, or minLength and maxLength of these arrays?


Solution

  • I think you're asking whether you can include the minimum/maximum length in the type expressions (for example, Array.<string>).

    In short, the answer is no. You'll need to document the minimum/maximum length in the description of each array.