I have one enum that I would like to do reverse mapping so eventually I have one object with key as enum.value and value as enum's key I can hardcode all key-value pair but how can I write something more dynamic?
export declare enum SAMPLE {
AIR = 0,
EARTH = 1,
WATER = 2
}
REVERSESAMPLE {
SAMPLE.AIR = 'Air',
SAMPLE.EARTH = 'Earth',
SAMPLE.WATER = 'Water',
}
You don't need to do this. Sample[0] => "Air" And Sample.Air => 0