- Error
- Reported by the type checker
TS2555
Expected at least {0} arguments, but got {1}.
A function with optional or rest parameters is called with too few arguments. Pass at least the required ones.
What it means
Like TS2554, but for functions whose parameter list doesn't have a fixed length (it has optional or rest parameters), so the message gives the minimum instead of an exact count.
Example
function join(sep: string, first: string, ...rest: string[]): string {
return [first, ...rest].join(sep);
}
export const s = join(",");
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(4,18): error TS2555: Expected at least 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 at least the required arguments.
- Make a parameter optional if callers may leave it out.