Enums (short for enumerations) are a feature in TypeScript that allows you to define a set of named constants — values that are logically grouped together.

Instead of using strings or numbers directly throughout your code, Enums help make your code more readable, type-safe, and organized.

There are two main types:

Numeric Enums (default)

String Enums

Example:

enum Direction {
  North,
  South,
  East,
  West,
}
function move(direction: Direction) {
  console.log("Moving", direction);
}

Enums can also be assigned specific values:

enum Role {
  Admin = 'ADMIN',
  User = 'USER',
  Guest = 'GUEST'
}

Now your logic can depend on a clear, strict set of roles or directions.