How they're out.
A fixed set of named outcomes — that's an enum.
Every dismissal in cricket has a name. Bowled. LBW. Caught. Run out. Stumped. The scorer doesn't invent new ones. The book has its categories, and every wicket falls into one of them.
An enum in TypeScript is exactly that — a fixed list of named members under a single type. Use the name (Dismissal.Bowled) instead of a raw number; the code reads itself, and the compiler still knows it's one of a known set.
Tap a dismissal. Watch the wicket fall, and the scorer write it down by name.
Five members. One type. Names you can read.
An enum binds a fixed set of names to a single type. By default each member gets a number — Bowled is 0, LBW is 1, and so on. But callers write the name, not the number.
enum Dismissal { Bowled, LBW, Caught, RunOut, Stumped, } function recordOut(d: Dismissal): string { return `Out: ${Dismissal[d]}`; } recordOut(Dismissal.Bowled); // 'Out: Bowled' recordOut(Dismissal.Caught); // 'Out: Caught'
Names beat magic numbers.
Without the enum, you'd write recordOut(2) and hope the reader knows 2 means caught. With it, you write Dismissal.Caught — the meaning is in the call site, not in a comment.
Reach for an enum when a value belongs to a small, named set that won't grow much. Type aliases work too — but enums shine when the names matter as much as the values.