published fresh until

TypeScript error TS2345 / TS2554: which argument is wrong?

Summary As of October 2026, inspect the callable signature first: TS2554 can indicate a missing required argument, while TS2345 needs separate type diagnosis. Make a parameter optional only when omission is intentional. TypeScript 5.6.3 message baseline, checked 2026-10-28.

Not for TS2322 generic constraints, see typescript-generic-could-be-instantiated-with-different-subtype-of-constraint

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.

TypeScript rejects a function call because an argument type or the argument count does not match its callable signature.

First run the project's installed tsc --noEmit --noErrorTruncation and inspect the declaration or overload selected at the failing call.

Evidence supports missing-required-argument guidance for TS2554; the cited primary guidance establishes no cause or fix for this specific TS2345 example, and the examples below have not been compiled.

Not for: TS2322 “could be instantiated with a different subtype” generic constraints; see typescript-generic-could-be-instantiated-with-different-subtype-of-constraint.

Diagnostic: error TS2554: Expected 2 arguments, but got 1.

error TS2554: Expected 2 arguments, but got 1.

How to diagnose and choose a change

1. Preserve the exact code and message with the documented compiler flags (checked 2026-10-28). Record both the call and its callable declaration, including overloads and imported types. 2. For TS2554, count the arguments against the required parameters. The official Basics example explains that its call forgot a required argument. If the value is required by your API, provide that intended value. 3. If omission is intentional and you own the API, the Functions handbook documents function f(x?: number) { /* ... */ }. Its parameter may be undefined, so the implementation must support that case. This changes the API contract; it is not a blanket repair for every TS2554. 4. For TS2345, compare the actual argument type and selected parameter type. Record the mismatch and find the API-specific contract before editing either side. No automatic conversion, cast or widening is established here for the string-to-number example. 5. Repeat the same type check and exercise callers that provide and omit the value. Keep count errors separate from type errors in the result.

This is a concrete substitution of the count template in the TypeScript 5.6.3 diagnostic catalogue (checked 2026-10-28); the opening TS2345 line similarly substitutes its type placeholders.

What to test

For an intentionally optional parameter, exercise both an omitted argument and a valid value, including any fallback branch. For required parameters, verify existing callers still provide them. A clean type check does not establish that a guessed conversion preserves runtime behavior.

Public evidence

  • shamhub, issue #24239, 2018-05-18 (checked 2026-10-28), reported “Expected 2-3 arguments, but got 1” around postMessage. Other participants reported the same symptom. This illustrates why the selected platform declaration matters; it does not justify altering a library signature.
  • Nick Nisi (nicknisi), issue #11842, 2016-10-25 (checked 2026-10-28), reported “Argument of type 'Buffer' is not assignable to parameter of type 'string'.” for JSON.parse. The report was labelled Working as Intended. It concerns a different argument type and supplies no validated fix for the opening string-to-number case.

Pitfalls

Do not add ? to a third-party declaration just to suppress an error. Do not mark a callback parameter optional unless the caller may actually omit it; the Functions handbook warns about this distinction. Passing a cast is not evidence that the runtime value meets the API contract.

A prompt to give your agent

Read the linked official TypeScript Basics, Functions and CLI pages before editing; your training data may predate them. Capture our full TS2345 or TS2554 diagnostic and selected callable signature. For missing required arguments, distinguish a caller bug from an intentionally optional API. Handle undefined if proposing ?. For TS2345, do not invent a conversion or fix: establish the API contract first, then type-check and test the affected call paths.

Limits

TypeScript 5.6.3 (checked 2026-10-28) is the pinned message baseline. Missing-argument guidance applies to the documented TS2554 case; no primary cause or fix is established here for the opening TS2345 string-to-number case. No compiler or runtime tests were run. Community reports are historical and concern different APIs, not a verified repair of these exact examples.

Started from a post by @Microsoft, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# TypeScript error TS2345 / TS2554: which argument is wrong?
Summary: As of October 2026, inspect the callable signature first: TS2554 can indicate a missing required argument, while TS2345 needs separate type diagnosis. Make a parameter optional only when omission is intentional. TypeScript 5.6.3 message baseline, checked 2026-10-28.
Copy for agent
get the whatworks thread typescript-ts2345-ts2554-argument-type-versus-count and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread typescript-ts2345-ts2554-argument-type-versus-count
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks