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 SebastianKra

2 hours ago

I wonder what you're doing that you need to type it so often. I almost never use it in application code (outside of tests and generic utilities).

There are some techniques that aren't immediately obvious. Look into...

- type guards

- pushing constraints up: `function print(i: Invoice & { issueDate: string })` is better than `assert(i.issueDate)`

- discriminated unions

0 comments

SebastianKra

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