Covariance
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
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."
Related Terms
Contravariance
Contravariance is covariance's weird sibling that goes the opposite direction.
Polymorphism
Polymorphism means the same method call can do different things depending on which object it's called on. Call 'speak()' on a Dog and you get a bark.
Structural Typing
Structural typing is TypeScript's dating philosophy: it doesn't care about your name, only your shape.
TypeScript
TypeScript is JavaScript with a strict parent watching over it.