Support Tuples
In TypeScript, it is possible to define Tuples, which are just arrays with specific types at each index. It would be awesome if JSDoc could understand those as well. Having this would help with mixing TS and JS with JSDoc.
I’m not exactly sure if JSDoc has to follow the Closure Compiler’s standards, but there is an open issue for the same thing there.
This is kind of related to #1073 but slightly different as that issue mentions documenting the elements themselves while my proposal is to allow documenting for the type/shape of an array.
Expected behavior
/**
* @typedef {[number, number, number]} Vector3
*/
let a = []; // invalid, length is 0 (and don’t know type)
let b = [1]; // invalid, length is 1, should be 3
let c = [1, 2, 3]; // valid
let d = ["hello", 2, 3]; // invalid, index 0 is a stringCurrent behavior
Right now, the only way to specify this is with a simple number[] array, but this isn’t specific enough. Having this could allow for typing such as Object.entries, which returns a [string, T] (T being the Object’s value type but that’s not too relevant for this).
Source: jsdoc/jsdoc