Skip to content

Files

Latest commit

 

History

History
29 lines (23 loc) · 453 Bytes

no-const-enum.md

File metadata and controls

29 lines (23 loc) · 453 Bytes

Pattern: Use of const enum

Issue: -

Description

const enum in TypeScript is incompatible with bundlers and isolatedModules mode. The values are inlined at use sites, which can lead to importing nonexistent values after bundling.

Examples

Example of incorrect code:

const enum Direction {
  Up,
  Down,
  Left,
  Right
}

Example of correct code:

enum Direction {
  Up,
  Down,
  Left,
  Right
}