minArrayLength
The minArrayLength
modifier is used to contraint length ofarray
values. It also changes the return validation type – tuples with given number of elements are returned instead of arrays:
As a result, it makes using such arrays/tuples more typesafe. Notice how the type of the thirdElement
is different:
#
Type instantiation is excessively deep and possibly infiniteOn rare occasions you may come across the following TypeScript error: Type instantiation is excessively deep and possibly infinite.ts(2589). It's a limitation of the TypeScript compiler when used on very deeply nested conditional types such as the tuples generated by the minArrayLength
modifier.
Should this issue ever occur to you, please override the inferred generic parameter with number
: