'In typescript, why is a union of enums not also an enum?
I have two enums that I would like to union.
enum Color {
RED = 'red',
BLUE = 'blue',
}
enum Shape {
CIRCLE = 'circle',
SQUARE = 'square',
}
However when I declare a union type and attempt to reference a member:
type ColorShape = Color | Shape;
const test: ColorShape = ColorShape.RED;
I get a compile time error:
TS2693: 'ColorShape' only refers to a type, but is being used as a value here.
Why is this? Would an union of enums not also be an enum itself?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
