TypeScript
4 posts
Teaching TypeScript to Read Your Mind: Type Narrowing and Type Guards
A breakdown of how typeof, instanceof, in, and custom type guards let TypeScript shrink a union type inside a conditional — paired with discriminated unions to write safe code without sprinkling type assertions everywhere.
Conditional Types and Template Literal Types: Making TypeScript Compute Your Types
How Conditional Types branch at the type level, how infer pulls values out of nested types, and how Template Literal Types build new string literal types from templates — so you can write TypeScript types that are more precise and infer themselves automatically.
Generics 101: Reusable Functions and Types Without Sacrificing Type Safety
Starting from the pain of copy-pasting a function for every type it needs to support, this walks through how generics let functions and types stay both reusable and type-safe — no trade-off required.
TypeScript's interface vs. type: What's Actually Different?
Break down the real differences between interface and type — declaration merging, extension syntax, and union types — and build a decision framework so you're not just guessing every time.