Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardTypeScriptstructural typing unsoundnessSingle-choice MCQ

Under `strictFunctionTypes`, why does the method-syntax handler get accepted while the arrow-property handler with an identical parameter type gets rejected when widening the parameter to a supertype?

interface Animal { name: string } interface Dog extends Animal { bark(): void } declare let hm: { handle(a: Dog): void }; declare let hp: { handle: (a: Dog) => void }; const m: { handle(a: Animal): void } = hm; // OK const f: { handle: (a: Animal) => void } = hp; // ERROR