Error AtlasError Documentation and Resolution

TypeScript found a value that is not assignable to the target type

error TS2322: Type 'X' is not assignable to type 'Y'.

TypeScript rejected an assignment because the value's type is incompatible with the declared or inferred target type.

error TS2322: Type 'X' is not assignable to type 'Y'.
  • The assigned value does not match the variable, property, or return type.
  • A union, generic, or inferred type is narrower than the value being assigned.
  • A refactor changed one side of the assignment without updating the other.
  1. Inspect both sides of the assignment and confirm what type TypeScript expects.
  2. Narrow or transform the value before assigning it if the runtime value is broader than the target type.
  3. Only widen the declared type if the broader value is genuinely valid throughout the code path.
TypeScript Docs: Understanding Errors
TS2322 Type is not assignable to type: causes and fixes | Error Atlas