TypeScript Diagnostic

How to Fix TypeScript Error TS2322: "Type 'X' is not assignable to type 'Y'"

The value being passed or assigned has a type shape incompatible with the declared variable or parameter type (such as string assigned to a literal union).

TS2322: Type is not assignable to type

Quick Fix Checklist

  1. Use "as const" on literal objects or variables to preserve specific union types
  2. Provide default fallback for optional values: name ?? ""
  3. Ensure function return types match contract declarations