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” aroundpostMessage. 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'.” forJSON.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