Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardTypeScriptmethod bivariance strictFunctionTypesSingle-choice MCQ

With `strictFunctionTypes` on, why does this assignment of `Comparator<Dog>` to `Comparator<Animal>` still compile, exposing a known soundness hole?

type Animal = { name: string }; type Dog = Animal & { bark(): void }; interface Comparator<T> { compare(a: T, b: T): number } declare let cDog: Comparator<Dog>; let cAnimal: Comparator<Animal> = cDog; // compiles