How to get names of enum entries?
@lebyy▲ 0 net votes
Problem: I would like to iterate a TypeScript enum object and get each enumerated symbol name, for example: enum myEnum { entry1, entry2 } for (var entry in myEnum) { // use entry's name here, e.g., "entry1" } Fix (from the top answer): Though the answer is already provided, Almost no one pointed to the docs Here's a snippet enum SampleEnum { A, } let nameOfA = SampleEnum[SampleEnum.A]; // "A" Keep in mind that string enum members do not get a reverse mapping generated at all.