Skip to content
Latchkey

TS2345: Argument is not assignable - in CI

You passed an argument whose type does not match the parameter a function expects.

What this error means

Type-checking fails with TS2345 at a call site, naming the argument type and the expected parameter type.

tsc
src/cart.ts(18,14): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.

Common causes

How to fix it

Make the argument match the parameter

  1. Convert or narrow the value before the call
  2. Avoid as casts that silence the error without fixing it
ts
addToCart(Number(productId))

Fix the signature if the type is too narrow

  1. Widen the parameter type deliberately (e.g. string | number)
  2. Update calls to a dependency's new shape

How to prevent it

  • Run tsc --noEmit in CI, enable strict, and convert at boundaries instead of casting.

Frequently asked questions

What causes "TS2345 argument not assignable"?
Type-checking fails with TS2345 at a call site, naming the argument type and the expected parameter type.
How do I fix TS2345 argument not assignable?
Make the argument match the parameter

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card