TypeScript
Types that pay for themselves: narrowing, inference, config and migration notes.
2025
- satisfies vs a type annotation in TypeScriptUse satisfies to check a route table while retaining its actual keys and HTTP method types.
- Stop unions splitting in conditional typesWrap both sides of a conditional type in tuples to check a union as a whole.
- Exhaustive switch with a never checkAdd a never check to a switch so TypeScript names any union member the switch leaves unhandled.
- String unions vs enums vs as const objectsUse a string union for type checking and derive it from an as const object when you also need the values at runtime.