filmov
tv
Typescript: create a Non empty array type
Показать описание
#shorts
In typescript: Is it possible to declare a NON-EMPTY array type and take advantage of the Typescript compiler's power to check that type?
Of course, it is possible!
In this article, I tell you how:
• Create a `NonEmptyArray` type.
• Use Type Guards.
TLDR;
• Uses "rest parameters" (Variadic Tuples).
• Creates a Type Guard.
In typescript: Is it possible to declare a NON-EMPTY array type and take advantage of the Typescript compiler's power to check that type?
Of course, it is possible!
In this article, I tell you how:
• Create a `NonEmptyArray` type.
• Use Type Guards.
TLDR;
• Uses "rest parameters" (Variadic Tuples).
• Creates a Type Guard.