TypeScript Tricks I Actually Use Day to Day
typescript
dev.to
I've been writing TypeScript for a few years now across React Native, Node.js, and a bunch of different product types. And there's a gap between what the docs teach you and what you actually end up reaching for every day. Here are the patterns I keep coming back to. Discriminated unions for state management This one changed how I model data. Instead of a bunch of optional fields that may or may not exist, you define each state explicitly. type RequestState = | { status: "idle" } | { stat