TypeScript · maintainability
no-enum
eslint:no-enum Disallow TypeScript `enum`; use string-literal unions or `as const` objects instead.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
TypeScript enums emit runtime objects and numeric enums accept values outside their declared members, adding behavior where a type-only model is sufficient.
Fix
Replace the enum with a string-literal union or an `as const` object and derive its value type from that object.
Before / after
Executed by this rule’s unit tests.
Before
A numeric enum emits a mutable runtime object
enum Status { Active, Inactive } After
A string-literal union has no emitted runtime enum
type Status = "active" | "inactive"; Message IDs
noEnum