3 ms·
> Hmm, what did I miss, why do people hate them exactly? They operate in a weird gray-zone between being just compile-time types vs. an actual readonly object
by tengbretson 6y ago
> Hmm, what did I miss, why do people hate them exactly?
They operate in a weird gray-zone between being just compile-time types vs. an actual readonly object in the runtime. I don't think I've seen a use case for them yet that wouldn't have been better accomplished with a union type of string literals and using const string literals in the code.
- folkrav 6y agoSay all you need is a fixed set of strings that get reused everywhere. What is better accomplished by defining a union type AND consts literals rather vs creating a single string-based enum and using that everywhere? I feel like I'm misunderstanding...
- mssundaram 6y agoYou don't even need the const literals. type Color = "red" | "blue" | "green";