ProjectStack
typescript

TS2345: Argument of type 'X' is not assignable to parameter of type 'Y'

You're calling a function with an argument whose type doesn't match what the function's parameter expects. This is the function-call version of TS2322 — the same type mismatch concept applied at the call site.

Common causes

  • Passing a string where the function expects a number, or an object where it expects a specific interface
  • Passing null or undefined to a function that doesn't accept those values
  • The function expects a more specific type than what you're providing (e.g., expects 'GET' | 'POST' but you pass a plain string)
  • A callback function's signature doesn't match what the higher-order function expects

How to fix it

  1. Cast the argument to the expected type if you're certain it's safe: fn(value as ExpectedType)
  2. Use as const to narrow a literal type: const method = 'GET' as const
  3. Update the function's parameter type if it's too restrictive and the broader type is safe
  4. Add a null check before passing: if (value !== null) { fn(value) }

Example

function greet(name: string) { return 'Hello ' + name; } greet(42); // error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.

Calling a function that expects a string with a number argument

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.