I have a typescript enum that looks like this:
enum State {
NotRequired,
Working,
PendingReview,
Reviewed,
Done
}
And this generates this:
var State;
(function (State) {
State[State["NotRequired"] = 0] = "NotRequired";
State[State["Working"] = 1] = "Working";
State[State["PendingReview"] = 2] = "PendingReview";
State[State["Reviewed"] = 3] = "Reviewed";
State[State["Done"] = 4] = "Done";
})(State || (State = {}));
I would like to have the values a nicely formed string with spaces where required.
So State[State["PendingReview"] = 2] = "PendingReview"; would become State[State["PendingReview"] = 2] = "Pending Review";
I have managed to achieve something close to this by defining my enum like so:
enum State {
"Not Required",
Working,
"Pending Review",
Reviewed,
Done
}
However this has the drawback that to use any enum value in code with a space i now have to use my key instead.
So State.PendingReview now has to be used like this State["Pending Review"]
Can i have the best of both worlds by somehow defining an alternative display string to my key?
So that when i say State[State.PendingReview] it gives me the value "Pending Review"