"Make the common case write less."
The syntax
Default type parameters use the same = syntax as default function parameters: type Result<T, E = Error> says "if the caller doesn't supply E, use Error." The default applies only when the caller leaves the slot unfilled.
This is purely an ergonomic feature — every default is also expressible by writing the type out at call sites. Defaults exist to make 80% cases concise without giving up the 20%.
Common uses
- Error type defaults to Error:
type Result<T, E = Error> - State type defaults to empty object:
type Action<S = {}> - Element type defaults to unknown:
type Container<T = unknown> - Component props defaults to empty:
type Component<P = {}>
Constraints + defaults
You can combine: <T extends Constraint = Fallback>. The default must satisfy the constraint. If it doesn't, the compiler errors at the declaration, not the call site. This is how libraries provide both safety (via constraints) and convenience (via defaults).
Default type parameters trade flexibility for brevity in the common case. Use them when there's an obvious default and most callers will use it. Don't overuse — too many defaults make the type's intent unclear.