With Recursive conditional types (added in TypeScript 4.1.0) it is possible to:
xxxxxxxxxx
type Tuple = N extends N ? number extends N ? T[] : _TupleOf : never;
type _TupleOf = R['length'] extends N ? R : _TupleOf;
Then you can use the type:
xxxxxxxxxx
const stringTupleOfLength3: Tuple = ['foo', 'bar', 'baz'];
xxxxxxxxxx
TypeScript has tuple types which let you define an array with a specific length and types:
let arr: [number, number, number];
arr = [1, 2, 3]; // ok
arr = [1, 2]; // Type '[number, number]' is not assignable to type '[number, number, number]'
arr = [1, 2, "3"]; // Type '[number, number, string]' is not assignable to type '[number, number, number]'