Assuming these are my enums:
enum Direction {
Up = `1`,
Down = '2',
Left = '3',
Right = '4',
}
enum Direction2 {
Up = Direction.Up
}
The above case is valid as long as the value of 2nd enum is from another Enum. But why this is not valid?
enum Direction2 {
Up = Direction.Up,
Down = '2'
}
I have looked into the typescript enum doc but cannot find any reason for it. From what I'm seeing, both values in Direction2 is a string, and there should be allowed. I'm aware this can be worked around if I change Direction2 to a json:
let Direction2 = {
Up: Direction.Up,
Down: '2'
}
but I would prefer to keep it as an enum.