Enums give names to related values.
Direct answer
An enum is a named group of constants. Numeric enums assign numbers starting at 0, and string enums assign text. Enums produce real JavaScript code. Many developers prefer union types of string literals for simplicity.
Examples
enum Status {
Active = "ACTIVE",
Inactive = "INACTIVE",
}
function setStatus(s: Status) {}
setStatus(Status.Active);
The union alternative
type Status = "active" | "inactive";
function setStatus(s: Status) {}
setStatus("active");
Const object alternative
const Status = { Active: "active", Inactive: "inactive" } as const;
type StatusType = typeof Status[keyof typeof Status];
Which to choose
- Union types for most cases.
- Enums when you want a named object with values at runtime and your team prefers them.
Where Teyro fits
Teyro's TypeScript for Beginners course turns this into short lessons you can play in a few minutes a day. It has 20 lessons, and you can start free.
The bottom line
Both work. Follow your team's convention.



