how to convert number to enum in typescript code example
Example 1: typescript enum value to enum
enum Number {
One,
Two
}
const numberOne: Number = "One" as Number;
const otherNumberOne: Number = Number.One;
const stringOne = Number[Number.One];
Example 2: enum to number typescript
enum UserResponse {
No = 0,
Yes = 1,
}
console.log(UserResponse.Yes) //logs : 1