Ad Space — Top Banner

TS2554

TypeScript Programming Language

Severity: Minor

What Does This Error Mean?

TypeScript error TS2554 means you called a function with the wrong number of arguments. The function definition says it expects a certain number of parameters, but your call passes more or fewer. TypeScript catches this at compile time so the mismatch never reaches production. The fix is to check the function's signature and adjust your call to match — either by passing the right number of arguments, or by updating the function definition to accept optional parameters.

Affected Models

  • TypeScript 1.0 and later
  • All TypeScript versions
  • tsc compiler, ts-node, all TypeScript toolchains

Common Causes

  • Calling a function with too few arguments when some parameters are required
  • Calling a function with too many arguments when the function does not accept extra parameters
  • A function signature was updated (parameters were added or removed) but all the call sites were not updated to match
  • Confusing a function that takes an options object (one argument) with one that takes individual parameters (multiple arguments)
  • Using a third-party library where the type definitions describe a different function signature than the actual JavaScript

How to Fix It

  1. Hover over the function name in VS Code to see its full signature — the parameter names, types, and whether any are optional. This tells you exactly what the function expects.

    VS Code shows the full function signature in a tooltip when you hover. This is faster than searching for the function definition manually.

  2. If you called with too few arguments, check which parameters are required versus optional. Required parameters have no ? and no default value. Add the missing arguments to your function call.

    TypeScript marks optional parameters with a ? after the name: function greet(name: string, greeting?: string). The greeting parameter is optional — you can omit it.

  3. If the function does not need one of its required parameters in your use case, update the function definition to make that parameter optional by adding ? after its name: function myFn(required: string, optional?: number).

    Only do this if the function genuinely does not always need that argument. Do not make things optional just to silence the error if the value is truly always required.

  4. If you called with too many arguments, remove the extra ones. Check whether you may have confused two similar functions — one that takes individual values and one that takes an options object.

    A common mistake is calling fn(a, b, c) when the function was recently refactored to fn(options) where options is an object containing a, b, and c.

  5. If you need a function that can accept a variable number of arguments, use a rest parameter. Example: function sum(...numbers: number[]): number {}. This accepts any number of number arguments.

    Rest parameters (the three dots ...) let a function accept zero or more arguments of the same type. The arguments arrive inside the function as an array.

When to Call a Professional

TS2554 is always a fixable code error. No outside help is needed. The error message tells you exactly how many arguments were expected and how many you provided.

Frequently Asked Questions

Why does TypeScript care about argument count when JavaScript does not?

JavaScript silently ignores extra arguments and sets missing ones to undefined. This means a wrong argument count in JavaScript often causes a silent bug — the function runs but produces a wrong result. TypeScript catches this upfront at compile time, which prevents a whole category of runtime surprises that are hard to debug.

I am getting TS2554 but I can see the function takes more parameters when I look at its source. Why?

The TypeScript types and the actual JavaScript implementation can be out of sync. This is common with third-party libraries where the .d.ts type definition file is outdated. Try updating the library or its @types package. You can also check the library's changelog to see if the function signature changed in a recent version.

What is the difference between an optional parameter and a default parameter?

An optional parameter uses ?: function fn(x?: string). Inside the function, x is string | undefined — you must check before using it. A default parameter uses =: function fn(x: string = 'hello'). Inside the function, x is always a string — it uses 'hello' if the caller omits it. Both can be omitted by the caller, but a default parameter is easier to work with inside the function.