Hacker News new | ask | show | jobs
by iLoveOncall 1612 days ago
> Enums IMO have no advantage over union types with string literals, e.g. `type Status = 'fulfilled' | 'pending' | 'failed'`.

Well I would say having to not repeat and update your code everywhere when you change or add a possible value is a pretty big advantage.

2 comments

In my experience, even if I do change an enum value I also want to change the name in code. Having enum { complete = 'finished' is a little weird so I just change it to enum { finished = 'finished' } anyway.
My IDE does this just fine (WebStorm, btw)
But the peer who reviews your code will hate it.
No, it was a team choice.
Ok, that's good.