https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
https://www.typescriptlang.org/docs/handbook/2/everyday-type...
What value do you think it offers here?
If you just use the value within your code the runtime representation does not matter, you're completely right.
Usually it's just
enum Method {
Get = "GET"
// ...
}
I usually always put doc comments on enums and their variants.Regarding why numeric ones are (only sometimes) more useful than string values: bit flags comes to mind, faster comparison of numbers than strings (not always tho... unless this is a misconception, but I don't believe so), you mentioned smaller bundle size already.
As for "auto" enums: the fact they're numbers now is an implementation detail. They could be unique Symbols in a future versions of typescript. You can do that manually now too, but I'm talking about the automatic (without assignment) syntax.
Regarding article: I... Half-agree. But I'd not completely disregard/avoid enums. At the very least, they can be useful to help model some behaviours/states in more readable, accessible, and coherent way (Other comments went into a more in-depth defence of enums, thought).
enum Method {
Get = "method/GET"
// ...
}
The string value can be very helpful for the reader - be it a human or log ingestor