Extracts the length property type from a type T that has a numeric length property. Typically used for arrays and tuples.
length
T
A type with a length: number property (e.g., readonly unknown[]).
length: number
readonly unknown[]
The type of the length property (e.g., number for arrays, a number literal for tuples).
number
type TupleLen = Length<[1, 2, 3]>; // 3type ArrayLen = Length<string[]>; // numbertype StringLen = Length<"abc">; // 3 Copy
type TupleLen = Length<[1, 2, 3]>; // 3type ArrayLen = Length<string[]>; // numbertype StringLen = Length<"abc">; // 3
Extracts the
lengthproperty type from a typeTthat has a numericlengthproperty. Typically used for arrays and tuples.