DEV Community

Discussion on: We don't have to use Enums on TypeScript? 【Discussion】

Collapse
 
firstwhack profile image
FirstWhack • Edited

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.