Reverse mapping #9
Jack-Works
started this conversation in
General
Replies: 2 comments 3 replies
-
In https://github.com/rbuckton/proposal-enum, reverse mapping was not via element access on the constructor, but via a static method on an
|
Beta Was this translation helpful? Give feedback.
3 replies
-
There is another problem with reverse mapping. If multiple keys shared the same value, should reverse mapping return a list? enum A { A = 1, B = 1 }
A[Symbol.reversEnum] // ["A", "B"]? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The reverse mapping is the ability to get enum name from the enum value, for example, in TypeScript, you can do:
Problem
Should we support this use case?
This feature does not work well with inline-able (#4).
The TypeScript way only supports reverse mapping in number enum, if we want to support this use case, we should also support other kinds of enum.
Beta Was this translation helpful? Give feedback.
All reactions