Type 'X' is not assignable to type 'Y' in TypeScript (TS2322, TS2345): 10 Causes and Fixes (Tested Examples)
TypeScript reports Type 'X' is not assignable to type 'Y' when a value could be something the target type does not allow. Here are 10 real causes, from undefined and null to Promises, literal types, useState and generics, with real compiler output and fixes that keep your types honest.