Sentry Answers>Node.js>

Node.js "No overload matches this call." error with TypeScript

Node.js "No overload matches this call." error with TypeScript

Matthew C.

The Problem

When calling a TypeScript function, you may get the following error:

Click to Copy
No overload matches this call.

This error occurs when a function or method is called with arguments that don’t match any of the function’s overload signatures.

The Solution

Ensure that the arguments and types of your function call match one of the function’s overload signatures.

In TypeScript, you can use overload signatures to specify a function that can be called with a variable number of arguments, argument types, and return types.

Each overload signature defines the parameter and return types of the function. They don’t have a function body. You also need to define an implementation signature that has a function body. The types of the implementation signature functions should match all of the types of the overload signatures.

Click to Copy
// Overload signatures function combine(a: string, b: string): string; function combine(a: string[], b: string[]): string[]; // Implementation signature function combine(a: unknown, b: unknown): unknown { if (Array.isArray(a) && Array.isArray(b)) { return [...a, ...b]; } else if (typeof a === "string" && typeof b === "string") { return a + b; } throw new Error("Invalid arguments"); }

When calling the function, call it using the types of one of the overload signatures. If you call the function using arguments that don’t match one of the overload signatures, you’ll get the No overload matches this call error.

For example, you could call the combine function, defined above, with a number as its first argument, as follows:

Click to Copy
console.log(combine(1 , "world!"));

If you called the function above, you would get the following error:

Click to Copy
No overload matches this call. Overload 1 of 2, '(a: string, b: string): string', gave the following error. Argument of type 'number' is not assignable to parameter of type 'string'. Overload 2 of 2, '(a: string[], b: string[]): string[]', gave the following error. Argument of type 'number' is not assignable to parameter of type 'string[]'.(2769)

If, however, you called the combine function with two “string” arguments of the type “string”, you wouldn’t get any errors:

Click to Copy
console.log(combine("Hello, ", "world!"));

Function overloads should only be used when the function signature is complex:

Click to Copy
function combine( a: string | string[], b: string | string[] ): string | string[] { if (Array.isArray(a) && Array.isArray(b)) { return [...a, ...b]; } else if (typeof a === "string" && typeof b === "string") { return a + b; } throw new Error("Invalid arguments"); }

You should rather use union types when possible.

View TypeScript Playground Demos

You can see live demos of the examples in the TypeScript Playground:

Learn More

To learn more about function overloads, take a look at the TypeScript docs.

  • SentryWorkshop: Debugging your Node.js Project With Sentry
  • Syntax.fmListen to the Syntax Podcast
  • Community SeriesIdentify, Trace, and Fix Endpoint Regression Issues
  • ResourcesBackend Error Monitoring 101
  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2025 • Sentry is a registered Trademark of Functional Software, Inc.