TypeScript Generics and Advanced Type Operators
out variance annotation — covariant parameters
A covariant parameter preserves the direction of assignability between instantiations of the same generic type: a producer of a narrower type can serve where a wider output is allowed. TypeScript usually determines variance from usage; annotations describe instantiation relationships, not arbitrary structural comparisons. Use matching annotations rather than trying to override an incompatible member contract. Combining in and out can describe invariance. Example output: "ready". Local strict TypeScript 5.8.3 / ES2022 baseline. The type construct itself is erased; the logged value illustrates a checked use, not runtime type validation.
Formal Syntax & Structure
typescript syntaxtypescript
type Producer<out T> = { read: () => T };Working Example
Example Snippettypescript
type Producer<out T> = { read: () => T };const text: Producer<string> = { read: () => "ready" };const all: Producer<unknown> = text;console.log(all.read());