Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

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.

0 comments

scrollaway

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities