Type alias KeyOfArray<Input>

KeyOfArray<Input>: NeverFallback<Exclude<Partial<Input>["length"], Input["length"]>, number>

Get type of index of array (can be a const number or just a number).

Example

const lengthConst: Length<[1, 2, 3]> = 2; // Can be: 0 | 1 | 2
const lengthUnknown: Length<ReadOnlyArray<number>> = 10; // Can be any number

Type Parameters

  • Input extends ArrayLike<unknown>