TypeScript const Type Parameters: Inference That Stays Literal
const type parameters (TypeScript 5.0): when T extends readonly any[] infers tuples of literals, and how that replaces as const on every call.
1 min read
Tag
4 articles · 12 min of reading
const type parameters (TypeScript 5.0): when T extends readonly any[] infers tuples of literals, and how that replaces as const on every call.
How to pull types out of functions and promises with infer, why unions distribute, and the [T] trick when you do not want that.
Wildcard generics confuse most developers on sight, but the PECS rule turns a wall of question marks into a mechanical, memorable decision.
Generics keep the type information any throws away — how to write them, constrain them with extends, and know when a plain union is the better call.