Hacker News new | ask | show | jobs
by brundolf 1740 days ago
Many of these problems (some of which I didn't even know about because I avoid using enums) go away when you use union types instead. The implicit casting is one example, the display-name retrieval is another (assuming you use string literals for variants)

Some of them can worked around by structuring your code in certain ways (for example you could make sure every variant is covered by indexing into an object with `key in MyEnum`, or by returning from each switch case and requiring a particular return type)

But even setting those aside, I got burned so badly the last time I used Flow that I'm not sure anything could convince me to return to it