Is there some sort of standard to document tuples using JSDoc?
Given the following code, is this the correct way to document values at specific index positions in array?
/**
* @param {Array.<number,number>} tuple_variable description
* @param {number} tuple_variable[0] description
* @param {number} tuple_variable[1] description
*/
function document_tuple( tuple_variable: [number,number] ) {
// omitted
}
If you want a fully-expanded version that includes descriptions of each array element, something like this will work:
/**
* @typedef {number} MyTupleIndex0 - Description of index 0...
* @typedef {number} MyTupleIndex1 - Description of index 1...
* @typedef {[MyTupleIndex0, MyTupleIndex1]} MyTuple
* @param {MyTuple} tuple_variable
*/
function document_tuple(tuple_variable) {
// ommited
}
Or, more tersely, but without the descriptions:
/**
* @param {[number, number]} tuple_variable
*/
function document_tuple(tuple_variable) {
// ommited
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With