Common causes
- Passing a string literal ('active') where an enum value (Status.Active) is expected
- Numeric enums accept number assignments, but string enums require the exact enum member
- Comparing or assigning between two different enum types
- Getting an enum value from an external source (API, config) as a plain string
How to fix it
- Use the enum member directly: Status.Active instead of 'active'
- Cast with a type assertion if data comes from outside TypeScript: status as Status
- Import and use the enum value from wherever it's defined rather than repeating the string
- For API responses, validate and map to the enum: const status = data.status as Status
Example
enum Status { Active = 'active', Inactive = 'inactive' }
const s: Status = 'active';
// error TS2322: Type '"active"' is not assignable to type 'Status'.Assigning the string 'active' directly instead of using the Status.Active enum member
Browse more errors
The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.
