• Error
  • Reported by the type checker

TS2707

Generic type '{0}' requires between {1} and {2} type arguments.

A generic type gets too few or too many type arguments for its optional type parameters. Pass a count within the stated range.

What it means

The generic type has some type parameters with defaults, so it accepts a range of type argument counts. The reference passes a count outside that range.

Example

index.ts
type Pair<A, B = A> = [A, B];
let p: Pair<string, number, boolean>;
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(2,8): error TS2707: Generic type 'Pair<A, B>' requires between 1 and 2 type arguments.

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 between the minimum and maximum number of type arguments shown in the message.