Assigning a value whose type does not match the variable or property's type definition.
TS2322 is the primary type safety check in TypeScript. It indicates that you are attempting to assign a value of type X to a variable, parameter, or property that expects type Y, and TypeScript cannot guarantee type safety.
Common causes: passing string numbers instead of true numbers, missing optional fields in an object, assignability mismatch between nullable types (`string | null` vs `string`), or mismatching prop types in React components.
1interface UserProfile {2 id: number;3 name: string;4 role: 'admin' | 'user';5}6 7// Error: 'superadmin' is not assignable to 'admin' | 'user'8const currentUser: UserProfile = {9 id: 101,10 name: "Sarah",11 role: "superadmin"12};1interface UserProfile {2 id: number;3 name: string;4 role: 'admin' | 'user' | 'superadmin'; // Expanded union5}6 7const currentUser: UserProfile = {8 id: 101,9 name: "Sarah",10 role: "superadmin"11};Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
TypeScript inspects the `role` field in `UserProfile`, which allows only `'admin'` or `'user'`. Since `'superadmin'` is outside that union type, TypeScript flags TS2322 during compile time.