How to fix No overload matches this call in TypeScript

TypeScriptINTERMEDIATEMEDIUMUpdated Dec 11, 2025· 147 views

This TypeScript error occurs when you call a function with arguments that don't match any of its defined overload signatures. The fix involves checking the function's overload signatures, ensuring argument types match, or using type assertions when TypeScript can't infer the correct overload.

Quick fix

Fixes TS2769

// Example: document.createElement has multiple overloads
declare function createElement(tagName: "div"): HTMLDivElement;
declare function createElement(tagName: "span"): HTMLSpanElement;
declare function createElement(tagName: string): HTMLElement;

// This works - matches first overload
const div = document.createElement("div");

// This fails - "button" doesn't match specific overloads
const button = document.createElement("button"); // Error: No overload matches this call
  1. Check the function's overload signatures
  2. Fix argument type mismatches
  3. Handle union type arguments
  4. Use type assertions when necessary
typescript — error
// Example: document.createElement has multiple overloads
declare function createElement(tagName: "div"): HTMLDivElement;
declare function createElement(tagName: "span"): HTMLSpanElement;
declare function createElement(tagName: string): HTMLElement;
// This works - matches first overload
const div = document.createElement("div");
// This fails - "button" doesn't match specific overloads
const button = document.createElement("button"); // Error: No overload matches this call
No overload matches this call

What this error means

The "No overload matches this call" error (TS2769) appears when TypeScript cannot find a matching function overload for the arguments you're passing. TypeScript overloads allow a single function to have multiple call signatures with different parameter types and return types. When you call an overloaded function, TypeScript tries to match your arguments against each overload signature in order. If none match, you get this error. This typically happens when: 1. **Argument type mismatches**: You're passing arguments of the wrong type 2. **Missing optional parameters**: You're omitting required parameters or providing too many arguments 3. **Union type issues**: Your arguments have union types that don't match any single overload 4. **Generic constraints**: Generic type parameters can't be inferred from the arguments Overloads are common in library functions (like document.createElement, fetch, Array methods) and in your own code when functions need to handle multiple input patterns.

Typical symptoms

  • Compilation fails with 'No overload matches this call' error
  • IDE shows red underlines on function calls with specific arguments
  • Error appears when calling library functions with 'wrong' argument types
  • Code works with some argument combinations but fails with others
  • Error code TS2769 appears in compiler output
  • Autocomplete suggestions don't match the arguments you're passing

Common causes

  1. Passing arguments of incorrect types (string instead of number, etc.)
  2. Missing required parameters in function call
  3. Providing too many arguments to a function with fixed parameter count
  4. Union type arguments that don't satisfy any single overload signature
  5. Generic type parameters that can't be inferred from arguments
  6. Calling a function with an object literal that doesn't match expected interface
  7. Using rest parameters incorrectly with overloaded functions
  8. Version mismatch between TypeScript and library type definitions

How to fix "No overload matches this call"

1Check the function's overload signatures

First, examine the function's type definition to understand what overloads are available:

typescript
// Example: document.createElement has multiple overloads
declare function createElement(tagName: "div"): HTMLDivElement;
declare function createElement(tagName: "span"): HTMLSpanElement;
declare function createElement(tagName: string): HTMLElement;

// This works - matches first overload
const div = document.createElement("div");

// This fails - "button" doesn't match specific overloads
const button = document.createElement("button"); // Error: No overload matches this call

Hover over the function in your IDE to see available overloads. In VS Code, press Ctrl/Cmd and click the function name to jump to its definition.

2Fix argument type mismatches

Ensure your arguments match the expected types in the overload signatures:

typescript
// Example: Array.from has overloads for different input types
// Overload 1: Array.from<T>(arrayLike: ArrayLike<T>): T[];
// Overload 2: Array.from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];

// WRONG - second argument should be a function
const result1 = Array.from([1, 2, 3], "string"); // Error

// CORRECT - second argument is a mapping function
const result2 = Array.from([1, 2, 3], x => x * 2); // Works

// WRONG - object doesn't match expected interface
function process(options: { name: string }): void;
function process(options: { id: number }): void;

process({ title: "test" }); // Error - no overload matches

// CORRECT - matches one of the overloads
process({ name: "John" }); // Works
process({ id: 123 }); // Works
3Handle union type arguments

When arguments have union types, TypeScript needs each argument to match a single overload:

typescript
// Function with overloads
function format(input: string): string;
function format(input: number): number;

// WRONG - union type doesn't match any single overload
function processValue(value: string | number) {
  return format(value); // Error: No overload matches this call
}

// SOLUTION 1: Type narrowing
function processValue(value: string | number) {
  if (typeof value === "string") {
    return format(value); // Works - matches string overload
  } else {
    return format(value); // Works - matches number overload
  }
}

// SOLUTION 2: Add a union overload
function format(input: string): string;
function format(input: number): number;
function format(input: string | number): string | number; // Add union overload
function format(input: any): any {
  // Implementation
}

// SOLUTION 3: Use function overload with generic
function format<T extends string | number>(input: T): T;
function format(input: any): any {
  return input;
}
4Use type assertions when necessary

When TypeScript can't infer the correct overload, use type assertions:

typescript
// Example with fetch API
// fetch has overloads for RequestInfo (string | Request) and optional RequestInit

// WRONG - TypeScript can't infer which overload
const url: string | URL = Math.random() > 0.5 ? "https://api.com" : new URL("https://api.com");
fetch(url); // Error: No overload matches this call

// SOLUTION 1: Type assertion
fetch(url as string); // Assert it's a string
// or
fetch(url as Request); // Assert it's a Request

// SOLUTION 2: Narrow the type
if (typeof url === "string") {
  fetch(url); // Works - matches string overload
} else {
  fetch(url); // Works - matches Request overload
}

// Example with generic constraints
function process<T extends string | number>(value: T): T {
  // Some processing
  return value;
}

// WRONG - TypeScript can't match overload
const result = process(Math.random() > 0.5 ? "text" : 123); // Error

// SOLUTION - Add explicit type parameter
const result = process<string | number>(Math.random() > 0.5 ? "text" : 123);
5Check library type definitions and versions

Sometimes the error comes from mismatched type definitions:

bash
# Check TypeScript version
npx tsc --version

# Check if library types are installed
npm list @types/library-name

# Update TypeScript
npm install typescript@latest --save-dev

# Update type definitions
npm install @types/library-name@latest --save-dev

# If using a specific version, ensure compatibility
# Check the library's documentation for TypeScript version requirements

Common issues:
- Library updated but @types package hasn't been updated
- TypeScript version too old for new library features
- Conflicting type definitions from multiple @types packages

Check the library's GitHub issues for similar problems:

bash
https://github.com/DefinitelyTyped/DefinitelyTyped/issues?q=no+overload+matches
https://github.com/microsoft/TypeScript/issues?q=TS2769
6Refactor overloaded functions for better type inference

If you're writing overloaded functions, structure them for better type inference:

typescript
// POOR DESIGN - hard to match
function process(data: string, count: number): string;
function process(data: number, prefix: string): number;
function process(data: any, second: any): any {
  // Implementation
}

// BETTER DESIGN - use discriminated unions
type StringInput = { type: "string"; data: string; count: number };
type NumberInput = { type: "number"; data: number; prefix: string };
type ProcessInput = StringInput | NumberInput;

function process(input: ProcessInput): string | number {
  if (input.type === "string") {
    return `${input.data} repeated ${input.count} times`;
  } else {
    return `${input.prefix}${input.data}`;
  }
}

// EVEN BETTER - use function overloads with clearer signatures
function process(data: string, count: number): string;
function process(data: number, prefix: string): number;
function process(data: string | number, second: string | number): string | number {
  if (typeof data === "string") {
    // TypeScript knows second is number here
    return data.repeat(second as number);
  } else {
    // TypeScript knows second is string here
    return `${second}${data}`;
  }
}

// Add a catch-all signature if needed
function process(data: string, count: number): string;
function process(data: number, prefix: string): number;
function process(data: any, second: any): any; // Catch-all
function process(data: any, second: any): any {
  // Implementation
}

Advanced notes

### How TypeScript Resolves Overloads

TypeScript uses a process called overload resolution to determine which overload matches a function call:

1. Exact match checking: TypeScript looks for an overload where each parameter type exactly matches the argument type.
2. Subtype matching: If no exact match, TypeScript looks for overloads where argument types are subtypes of parameter types.
3. Order matters: Overloads are checked in the order they're declared. The first matching overload is used.
4. Contextual typing: In some cases (like callbacks), TypeScript uses the expected return type to help choose an overload.

### Common Pitfalls with Library Functions

React.createElement:

typescript
// React has specific overloads for intrinsic elements
const element1 = React.createElement("div"); // Works
const element2 = React.createElement("custom-component"); // Works
const element3 = React.createElement(Math.random() > 0.5 ? "div" : "span"); // Error!

Array methods:

typescript
// Array.prototype.map has overloads for different callback signatures
const arr = [1, 2, 3];
arr.map(x => x * 2); // Works
arr.map((x, i) => x * i); // Works
arr.map((x, i, a) => x * a.length); // Works

// But TypeScript can get confused with complex callback types
const callback: ((x: number) => number) | ((x: number, i: number) => number) =
  Math.random() > 0.5 ? (x) => x * 2 : (x, i) => x * i;

arr.map(callback); // Error: No overload matches this call

### Generic Overloads

Generic overloads can be particularly tricky:

typescript
function merge<T>(obj1: T, obj2: T): T;
function merge<T, U>(obj1: T, obj2: U): T & U;
function merge(obj1: any, obj2: any): any {
  return { ...obj1, ...obj2 };
}

// Works - same type
merge({ a: 1 }, { a: 2 }); // Returns { a: 2 }

// Works - different types
merge({ a: 1 }, { b: 2 }); // Returns { a: 1, b: 2 }

// Error - TypeScript can't decide which overload
merge({ a: 1 }, Math.random() > 0.5 ? { a: 2 } : { b: 2 });

### Using Conditional Types with Overloads

For complex scenarios, conditional types can sometimes replace overloads:

typescript
// Instead of multiple overloads:
function process(input: string): string;
function process(input: number): number;
function process(input: boolean): boolean;

// Use conditional type:
type ProcessResult<T> = T extends string ? string :
                       T extends number ? number :
                       T extends boolean ? boolean : never;

function process<T>(input: T): ProcessResult<T> {
  // Implementation
  return input as any;
}

const result1 = process("hello"); // string
const result2 = process(42); // number
const result3 = process(true); // boolean

### Debugging Overload Errors

Use TypeScript's compiler flags to debug:

bash
# Show detailed type information
npx tsc --noEmit --explainFiles

# Or add this to tsconfig.json
{
  "compilerOptions": {
    "diagnostics": true,
    "extendedDiagnostics": true
  }
}

The output will show which overloads were considered and why each was rejected.

Frequently asked questions

What does "TS2769" mean?
The "No overload matches this call" error (TS2769) appears when TypeScript cannot find a matching function overload for the arguments you're passing. TypeScript overloads allow a single function to have multiple call signatures with different parameter types and return types. When you call an overloaded function, TypeScript tries to match your arguments against each overload signature in order.
How do I fix "TS2769"?
This TypeScript error occurs when you call a function with arguments that don't match any of its defined overload signatures. The fix involves checking the function's overload signatures, ensuring argument types match, or using type assertions when TypeScript can't infer the correct overload.
What causes "TS2769"?
Passing arguments of incorrect types (string instead of number, etc.) Missing required parameters in function call Providing too many arguments to a function with fixed parameter count
Is the "TS2769" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading