TypeScript doesn't have a built-in non-empty array type, but you can define one using a tuple type: `type NotEmptyArray<T> = [T, ...T[]]`. This enforces at least one element at compile time. To prevent mutation-related issues (e.g., methods that could empty the array), a `ReadOnlyNotEmptyArray<T>` wraps it with `Readonly<>`. A
•2m read time• From playfulprogramming.com
Sort: