I want to achieve a fixed size array
type FixedLengthArray<T extends any, L extends number> = Array<T> & {
0: T,
length: L;
}
type ArrayValue = 'a' | 'b'
type Foo = FixedLengthArray<ArrayValue, 2>;
const foo1: Foo = ['a', 'b'];
But when I remove 0: T, it throws a error, and Array has defined [n: number]: T, what does '0' means.
Type '("a" | "b")[]' is not assignable to type 'FixedLengthArray<ArrayValue, 2>'.
Type '("a" | "b")[]' is not assignable to type '{ length: 2; }'.
Types of property 'length' are incompatible.
Type 'number' is not assignable to type '2'.