Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
s_severus
on Nov 8, 2019
|
parent
|
context
|
favorite
| on:
Parse, Don’t Validate
A possibly more elegant TypeScript solution:
type NonEmpty<T> = [T, ...T[]]; function head<T>(input: NonEmpty<T>): T { return input[0]; }
https://www.typescriptlang.org/play/?ssl=5&ssc=2&pln=1&pc=1#...
Consider applying for YC's Fall 2026 batch!
Applications
are open till July 27.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: