Comment by scrollaway
6 years ago
This SO answer is pretty clever: https://stackoverflow.com/a/56006703
type NonEmptyArray<T> = [T, ...T[]];
That is: A type of "NonEmptyArray" of T is an array of one element of type T, followed by any number of type-T elements.
No comments yet
Contribute on Hacker News ↗