TypeScript Syntax

const enum — compile-time enum member substitution

With the default non-isolated compilation settings, const enum member references are substituted with their values and the declaration is normally erased. preserveConstEnums can retain an emitted object. Avoid publishing ambient const enums without addressing isolated compilation and version-skew hazards. Observed output: '2'. Local verification: TypeScript 5.8.3, strict mode, ES2022, CommonJS, Node.js 22.16.0. Disposable library declarations are enabled for the fixture suite.

Formal Syntax & Structure

typescript syntaxtypescript
const enum Status { Draft, Ready }

Working Example

Example Snippettypescript
const enum State { Draft = 1, Ready = 2 }console.log(State.Ready);
TypeScript Reference