3 ms·
I really like JS/TS Combo. My only critic is the Enums - particularly the String enums. It is really an absolute mess.
by nvegater 5y ago
I really like JS/TS Combo. My only critic is the Enums - particularly the String enums. It is really an absolute mess.
- wruza 5y ago“Bare” enums are not better either. No introspection, bad debug-ability (you can’t print them in a human-readable way). Typescript enums are a good tradeoff between just string|string|… types and pure integers (or whatever type you assign to them). The former’s literals are indistinguishable from string literals at readsourcestime. The latter creates issues at debugtime.
- epolanski 5y agoUnion types are the way to go in 99% of cases you need enums.
- _jumble 5y agoYes, and generating those unions from a const array gives you even further flexibility with runtime access: `const myStrArray = ["a", "b", "c"] as const; type MyStrType = typeof myStrArray[number];`