Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
wruza
on Feb 2, 2022
|
parent
|
context
|
favorite
| on:
An introduction to type programming in TypeScript
Typescript’s type narrowing is useful for this exact situation:
// v is any or unknown if (typeof v !== "string") { throw new Error("oops") } // v is now string
You can’t get runtime type correctness by deceiving typescript into it.
Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: