- Error
- Reported by the type checker
TS2554
Expected {0} arguments, but got {1}.
A function is called with a different number of arguments than it declares. Pass the parameters it expects, or make extra ones optional.
What it means
The call has more or fewer arguments than the function's parameter list allows. Optional parameters and parameters with defaults may be left out; required ones may not, and extra arguments aren't allowed without a rest parameter.
Example
function add(a: number, b: number): number {
return a + b;
}
export const sum = add(1);
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(4,20): error TS2554: Expected 2 arguments, but got 1.
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 the missing arguments, or remove the extra ones.
- Make a parameter optional (
b?: number) or give it a default (b = 0) if it can be left out.