I am a frontend developer focused in creating application with React, Vue and Svelte. Currently, I am a software engineering student at Kasetsart University.
You can't index a union type unless you're creating a lookup table based on the union so "prefer unions" is simply unviable. This is what TS does but TS can remove that lookup at compile time for "const" Enums.
Don't reinvent core features.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Have you heard about
const enum
? It transplies to values only. E.g.results in
I think it's neat. ReScript also uses this approach. Also, you need a plugin if you use Babel.
This is cool. I just prefer Union types but this is great if this Enums gets stripped out when compiling! Thanks @nikolaymatrosov !
You can't index a union type unless you're creating a lookup table based on the union so "prefer unions" is simply unviable. This is what TS does but TS can remove that lookup at compile time for "const" Enums.
Don't reinvent core features.