Typescript: create a Non empty array type

preview_player
Показать описание
#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.
Рекомендации по теме