Explain 'Variance' and how 'strictFunctionTypes' affects architecture.
Updated May 4, 2026
Short answer
Variance describes how the subtyping of complex types (like functions) relates to their components; 'strictFunctionTypes' ensures safe parameter subtyping.
Deep explanation
In TypeScript, function parameters are 'contravariant'. This means you can assign a function that takes an Animal to a variable expecting a function that takes a Dog. Why? Because the Animal function is 'safer'—it can handle anything. The strictFunctionTypes flag prevents the opposite (bivariance), which was historically allowed but unsafe. High-level architecture requires understanding this to build safe generic event emitters or plugin systems.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro