TypeScript Cheat Sheet/Create a numeric enum

Declare a group of related named constants.

Section: Tuples and Enums

Create a numeric enum

typescript
typescript
enum Direction {
  Up,
  Down,
  Left,
  Right,
}
Explanation

Enums exist in TypeScript, though many teams prefer literal unions for simpler output.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Tuples and Enums
Use a string enum
Give enum members stable string values.
OpenIn sheettypescriptsame section
Declare a tuple
Model a fixed-size array with known positions.
OpenIn sheettypescriptsame section
Use named tuple members
Improve tuple readability with labels.
OpenIn sheettypescriptsame section
Initialize tsconfig
Create a starter tsconfig.json in the current project.
OpenIn sheetbash1 tag match
Annotate basic variables
Explicitly type strings, numbers, and booleans.
OpenIn sheettypescript1 tag match
Define an interface
Use an interface to model a reusable object shape.
OpenIn sheettypescript1 tag match