Skip to content

Covariance

Spicy — senior dev territoryGeneral Dev

ELI5 — The Vibe Check

Covariance means 'if a Dog is an Animal, then a Box of Dogs is also a Box of Animals.' It's the direction of type compatibility that makes intuitive sense — subtypes flow upward naturally.

Real Talk

A type system concept where a type constructor preserves the subtyping relationship of its type arguments. If Dog extends Animal, then ReadonlyArray is assignable to ReadonlyArray. Function return types are covariant — a function returning a more specific type can substitute one returning a broader type.

When You'll Hear This

"Return types are covariant — you can return a Dog from a function typed to return Animal." / "Arrays are covariant in TypeScript, which is technically unsound but practical."

Made with passive-aggressive love by manoga.digital. Powered by Claude.