News for hackers. Stuff that matters.
Re:TypeScript 2.4 by RyanCavanaugh on Tuesday June 27, 2017 @04:04PM (#14648873)
If there were a reverse map like for numeric enums, there'd be no way to (at runtime) distinguish a Name from a Value. With a numeric enum you can use typeof Test[x] to figure out if x was a valid Name or valid Value, but this doesn't work for string enums because they're both typeof == 'string'.
Re:TypeScript 2.4 by drk4 on Tuesday June 27, 2017 @05:44PM (#14649770)
That seems like a much minor situation compared to not being able to reverse map.

You could have a situation where you have a string as a code, and then the display name for example, and you can't really do that as is now. This seems more useful than checking for the type (which in a numeric enum is either a number or string, so you would still need to do some work to properly validate it).

Re:TypeScript 2.4 by RyanCavanaugh on Tuesday June 27, 2017 @07:40PM (#14650576)
If you want to have the reverse map, you can trivially build it yourself. But if the reverse map did exist (rather, if the map started off as bidirectional, which is the only option on the table), it'd be impossible to properly construct the one-way map.
Re:TypeScript 2.4 by drk4 on Wednesday June 28, 2017 @03:28AM (#14652314)
You mean because of using the same string for a key/value? I guess I see the potential problem. Anyway just think that it might be a bit confusing to have the enum work slightly different depending on whether its using numbers or strings. It can caught some people off guard.