Search⌘ K

Speeding Up Enum

Explore how setting enums as constant in TypeScript improves runtime speed and maintains type safety. This lesson covers the benefits, limitations, and compiler options related to constant enums, helping you optimize your TypeScript code efficiently.

Setting enum as const to increase speed

enum can be set as a constant to speed up the performance. This way, during execution, instead of referencing the function generated by TypeScript to JavaScript, it will use the value.

For example, without constant enum, ...