Enums in TypeScript Revisited
July 16, 2024A couple of years back, a colleague sent me an article detailing all the horrible things wrong with TypeScript enums. I read it, then I Googled "Are enums bad in TypeScript?" and read as much as I could find. OK, I was convinced, union types are much simpler than enums. They don't have any weird behaviour, you don't have to worry about type vs value confusion. Union types are types - they get stripped out at compile time. String literals are plain old JavaScript, they stay in at compile time.
Read more