Skip to content

oxc/no-const-enum Restriction

🛠️ An auto-fix is available for this rule.

What it does

Disallow TypeScript const enum

Why is this bad?

Const enums are enums that should be inlined at use sites. Const enums are not supported by bundlers and are incompatible with the isolatedModules mode. Their use can lead to import nonexistent values (because const enums are erased).

Example

ts
const enum Color {
  Red,
  Green,
  Blue,
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny oxc/no-const-enum
json
{
  "rules": {
    "oxc/no-const-enum": "error"
  }
}

References

Released under the MIT License.