• Error
  • Reported by the type checker

TS2344

Type '{0}' does not satisfy the constraint '{1}'.

A type argument doesn't meet the constraint of the type parameter it fills (`T extends ...`). Pass a type that satisfies it.

What it means

A type parameter declared as T extends C only accepts type arguments assignable to C. Giving it a type that isn't is reported at the type argument.

Example

index.ts
type Keys<T extends object> = keyof T;

export type K = Keys<string>;
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(3,22): error TS2344: Type 'string' does not satisfy the constraint 'object'.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Pass a type that satisfies the constraint.
  • If the constraint is too strict, relax it in the declaration.