TypeScript Master (50 Qs)•Part 3: Enterprise Architecture, Compiler Internals & Performance (Senior / Staff)
What is the difference between Method Signatures and Property Signatures in Interfaces?
senior LevelCode ExampleFormsPerformanceTypeScript
In Simple Words:
typescript
interface Comparer {
method(a: number): void; // Bivariant (under strictFunctionTypes)
property: (a: number) => void; // Contravariant (strictly checked)
}
Method shorthand syntax preserves legacy bivariance for compatibility with arrays, whereas function property syntax enforces strict contravariance under strictFunctionTypes.