4 ms·
An Enum in ts is weird. It's not just a type, it's something compiles to something in the runtime. So to use the value you have to import the Enum and use that
by crucialfelix 5y ago
An Enum in ts is weird. It's not just a type, it's something compiles to something in the runtime.
So to use the value you have to import the Enum and use that.
const handlers = {
'/': {
Verbs.GET: () => ....
Verbs.POST: () => ...
Whereas:
const handlers = {
'/': {
GET: () => ....
PAWST: //nope! must be one of GET | POST | PUT | DELETE
Basically it's a lot less work and you don't need to import the enum and maintain it.