Practical TypeScript reference covering the type system, advanced patterns, and real-world usage across different project contexts. Organized as runnable examples with inline commentary on non-obvious behavior.
| Area | Coverage |
|---|---|
| Core Types | Primitives, arrays, tuples, enums, union/intersection types |
| Type Narrowing | typeof, instanceof, discriminated unions, assertion functions |
| Generics | Generic functions, classes, constraints, conditional types |
| Utility Types | Partial, Required, Pick, Omit, Record, ReturnType, and more |
| Template Literals | Mapped types, template literal types, infer keyword |
| Modules | ES modules, declaration files, path aliases |
| Config | tsconfig.json options, strict mode, project references |
| Patterns | Builder pattern, factory functions, branded types, type guards |
src/
├── basics/ # Core type system and primitives
├── generics/ # Generic patterns and constraints
├── utility-types/ # Built-in utility type examples
├── advanced/ # Conditional types, infer, mapped types
└── patterns/ # Real-world design patterns in TypeScript
npm install
npx ts-node src/<topic>/index.tsOr compile and run:
npx tsc
node dist/<topic>/index.js- Node.js 18+
- TypeScript 5+