On this page
  1. enum
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

enum

Prev: `any` | Up: builtins | Next: `namespace`
Rel: as const, builtins, Structural Typing & Narrowing
Ref: TypeScript Docs — enum
Tags: #public #web #typescript #builtins #tier/legacy


Syntax & Overview

enum Direction { Up = 'UP', Down = 'DOWN' }

Generates runtime JavaScript IIFE objects (not erasable syntax; incompatible with Node --experimental-strip-types / erasableSyntaxOnly).

Legacy / Avoid: Prefer as const in all new code.

Notes & Pitfalls

Example

enum Status {
  Pending = "PENDING",
  Done = "DONE",
}

function isComplete(s: Status): boolean {
  return s === Status.Done;
}

Linked from

Related notes