enum key (Australia) from value (au) in Typescript?
Regions.au
Wont work
Object.entries(Regions).find(([k,v]) => v === Regions.Australia)[0]
https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
reverse mappings only work for numeric enums
right, that's strange
If there's a key with same name that'd cause problems
indeed, but i find it inconsistent
Then build another algorithm
Обсуждают сегодня