TypeScript 39 🔷 Variance and Type Compatibility
Variance describes how subtype relationships between types propagate through containers — arrays, functions, promises, and generics. If Dog is a subtype of Animal, is Dog[] a subtype of Animal[]? Is () => Dog a subtype of () => Animal? Is (x: Animal) => void a subtype of (x: Dog) => void? The answers depend on…