profileRyan KesPGP keyI build stuffEmailGithubTwitterLast.fmMastodonMatrix

TypeScript Enums

Syntax

enum CardSuit {
  Clubs,
  Diamonds,
  Hearts,
  Spades,
}

// Sample usage
var card = CardSuit.Clubs

// Safety
card = "not a member of card suit" // Error : string is not assignable to type `CardSuit`