I want to create a type where an array has a minimum length of N. I have looked at this TypeScript array with minimum length , but when N is large, I do not want to write out the type from 0 to N, e.g. :
type ArrayTwoOrMore<T> = {
0: T
1: T
...
N: T
}
I was wondering whether there was a neater way of doing this?
type ArrayTwoOrMore<T> = [T, T, ...T[]], but you still need to spell out all members, no way to say greater than Ntype Pair<T, U> = [T, U]andtype Tripple<T> = [T, T, T]I think @TitianCernicova-Dragomir answer is the best you can get with typescript in one line of code