The readonly array or tuple type to check.
type IsTuple = IsFixedLengthList<[1, 2, 3]>; // true
type IsArray = IsFixedLengthList<number[]>; // false
type IsReadonlyArray = IsFixedLengthList<readonly string[]>; // false
type IsEmptyTuple = IsFixedLengthList<[]>; // true
type IsTupleWithRest = IsFixedLengthList<[number, ...string[]]>; // false
Checks if a given readonly array type
Thas a fixed length (i.e., is a tuple). ReturnstrueifTis a tuple,falseif it's a regular array (Type[]).It works by checking if the general
numbertype is assignable to the specificlengthproperty ofT. For tuples,T['length']is a specific number literal (e.g.,3), andnumberis not assignable to3. For regular arrays,T['length']isnumber, andnumberis assignable tonumber.