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
- Cast the argument to the expected type if you're certain it's safe: fn(value as ExpectedType)
- Use as const to narrow a literal type: const method = 'GET' as const
- Update the function's parameter type if it's too restrictive and the broader type is safe
- 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.
