The NormalEnum to check
The value to get the key of
The name of the key with the specified value
const thing = {
one: 1,
two: 2,
} as const;
console.log(enumValueToKey(thing, 2)); // output: "two"
Throws an Error if an invalid enum value is passed to the function.
Return the name of the key that matches the given Enum value. Can be used to emulate Typescript reverse mapping for
const objects or string enums.