The enum member is initialized with a constant enum expression. A constant enum expression is a subset of TypeScript expressions that can be fully evaluated at compile time. An expression is a constant enum expression if it is: a literal enum expression (basically a string literal or a numeric literal) a reference to previously defined constant enum member (which can originate from a different ...
A const enum's value is replaced by TypeScript during transpilation of your code, instead of being looked up via an object at runtime. ... // If you look at the transpiled JavaScript, you can see how the other enums exist as objects and functions, however MouseAction is not there.
The default const enum behavior is to convert any Album.Something to the corresponding number literal, and to remove a reference to the enum from the JavaScript completely.
enum declarations namespace s and module s with runtime code parameter properties in classes Non-ECMAScript import = and export = assignments Here are some examples of what does not work: ... Similar tools like ts-blank-space or Amaro (the underlying library for type-stripping in Node.js) have the same limitations.
const enum (completely inlined enums) Enums are very useful, but some programs don’t actually need the generated code and would benefit from simply inlining all instances of enum members with their numeric equivalents. The new const enum declaration works just like a regular enum for type safety, but erases completely at compile time.