ProjectStack
typescript

TS2344: Type 'X' does not satisfy the constraint 'Y'

You're passing a type argument to a generic function or class that doesn't meet the constraints defined by the generic's extends clause. The constraint specifies the minimum shape a type must have to be used with that generic.

Common causes

  • Passing a primitive type (string, number) where the generic requires an object shape
  • The type is missing properties required by the constraint interface
  • Using a union type as a type argument when the constraint requires a single compatible type
  • A generic constraint changed in a library update and your type argument no longer satisfies it

How to fix it

  1. Make your type satisfy the constraint by adding the required properties
  2. Extend the required interface: interface MyType extends RequiredConstraint { ... }
  3. Check what the constraint requires: hover over the generic parameter in your editor
  4. Reconsider whether you're using the right type argument — you may need a different type

Example

function getProperty<T extends object, K extends keyof T>(obj: T, key: K) { return obj[key]; } getProperty('not an object', 'length'); // error TS2344: Type 'string' does not satisfy the constraint 'object'.

Passing a string where T extends object — strings don't satisfy the object constraint

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.