Get type of index of array (can be a const number or just a number).
index
const
number
const lengthConst: KeyOfArray<[1, 2, 3]> = 2; // Can be: 0 | 1 | 2const lengthUnknown: KeyOfArray<ReadOnlyArray<number>> = 10; // Can be any number
Get type of
index
of array (can be aconst
number or just anumber
).Example