All notes
Every note published on TypeScript in Production
Choose runtime structure and behavior
Choose TypeScript or Python for a Backend Service: Workload, Contracts, and Ownership
Choose the language around the service’s defining dependencies, then account for runtime validation, contract ownership, and the cost of operating another service.
Choose runtime structure and behavior
TypeScript Classes vs Modules: Should State Belong to an Instance or a File?
Use a class when callers need independently changing state; use a module to group operations and control what other files can import.
Validate inputs and enforce contracts
Model a TypeScript API Contract: Requests, Responses, and the Network Boundary
Define one user-update contract for a handler and client, then check actual request and response data before trusting its types.
Model data and type relationships
TypeScript Pick vs Extract: Select Properties or Union Variants
Use Pick to select fields from a type, Extract to retain matching union members, and Extract before Pick when the fields belong to only one variant.
Configure, migrate, and verify projects
Run a TypeScript Development Script with `tsx` and npm
Use `tsx watch` for a repeatable development command, then run type checking and compiled JavaScript as separate checks.
Configure, migrate, and verify projects
Initialize a TypeScript npm Project and Verify Strict Checking
Install TypeScript locally, configure a small Node.js project, and use an implicit-any error to check that strict settings apply to its source.
Model data and type relationships
TypeScript Mapped Types: Reuse and Transform Interface Properties
Use Pick to retain selected interface properties and their types, Partial to make them optional, and a mapped type when every property needs a new value type.
Configure, migrate, and verify projects
A Passing Playwright Test Is Not a Type Check: Add `tsc` to Your Workflow
Run Playwright for browser behavior and a separate TypeScript compiler check for test code; a pass from either tool answers a different question.
Model data and type relationships
How to Get an Array Element and Its Index in TypeScript
Use the second forEach callback parameter for an item’s index, or choose entries() or an indexed loop when they make the job clearer.
Model data and type relationships
TypeScript Record: Type a Fixed Key Set or an Open Dictionary
Use a finite key union when every named entry is required, and Record<string, Value> when the keys are open-ended.










