TypeScript 6.0 Enforces Strict Function Types by Default, Breaking Existing Callbacks

TypeScript 6.0 enables strictFunctionTypes by default, introducing contravariant parameter checking that can cause widespread compile failures in codebases that previously relied on bivariant behavior. The change means callbacks accepting a base type where a derived type is expected will no longer compile, breaking patterns that worked silently in earlier versions. A key distinction exists between method signatures, which retain bivariant checking for compatibility, and function properties, which now enforce contravariance. Teams are advised against silencing errors with 'any' or type assertions, as doing so undermines type safety and can reintroduce runtime bugs. Recommended migration paths include widening parameter types to unions, using method syntax where bivariance is intentional, or applying generic constraints to preserve assignability safely.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in