Skip to content

strictFunctionTypes: incompatible function signature

Quick summary

You assigned a function to a type that expects a different parameter variance — strictFunctionTypes catches the mismatch.

Why this happens

  • A function expecting a subtype is assigned to a type expecting a supertype, violating parameter contravariance

  • A callback with a specific parameter type is passed to a function expecting a more general callback type

  • An interface method is overridden with a parameter type that is narrower than the base interface

Minimal example

✗ Broken code
type Handler = (event: { type: string; data: unknown }) => void;
const handler: Handler = (event: { type: 'click'; data: MouseEvent }) => { // error
  console.log(event.type);
};
✓ Fixed code
type Handler = (event: { type: string; data: unknown }) => void;
const handler: Handler = (event) => { // accept the wider type
  console.log(event.type);
};

The handler must accept the wider type (type: string) that the Handler signature expects, not a narrower subtype (type: 'click').

How to diagnose

  • Read the TS error about type assignability and compare the two function signatures

  • Check whether the parameter types are in a subtype/supertype relationship that violates variance rules

  • Temporarily disable strictFunctionTypes to see if the error disappears, confirming it is a variance issue

How to fix

  • Widen the parameter type in the assigned function to match or exceed the target function type

  • Use a type assertion if you are certain the runtime behavior is safe despite the type mismatch

  • Redesign the interface to use a consistent parameter type hierarchy that satisfies variance rules

How to prevent

  • Understand function parameter contravariance — parameters should be wider, not narrower, in subtypes

  • Enable strictFunctionTypes and design interfaces with correct variance from the start

Related Resources

Related Glossary

Related Lessons

← Back to language