Skip to content
Latchkey

TS2322: Type is not assignable - in CI

You assigned a value whose type does not fit the declared type of the target.

What this error means

Type-checking fails with TS2322 at an assignment, a JSX prop, or a return statement, naming both types.

tsc
src/state.ts(8,3): error TS2322: Type 'string' is not assignable to type 'number'.

Common causes

How to fix it

Make the value match the type

  1. Convert or narrow the value at the boundary instead of forcing it
  2. Reproduce with tsc --noEmit locally to confirm
ts
const count: number = Number(raw)

Fix the declared type if it is wrong

  1. Widen the target type deliberately if it is too narrow (e.g. string | number)
  2. Update code to a dependency's new type shape

How to prevent it

  • Run tsc --noEmit in CI, enable strict, and avoid blanket as/any casts that mask real assignment errors.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →