I have this python code that I'm trying to convert to Javascript/Typescript
import enum
class Shape(enum.Enum):
RECTANGLE = 0
CIRCLE = 1
TRIANGLE = 2
OTHER = 3
print(isinstance(data, Shape))
In Typescript, I can use enums, but this is not what I'm looking for. I need the ability to do this:
const data = new Shape().RECTANGLE;
console.log(data instanceof Shape); // should return true
which wouldn't be possible to do using enums or objects.
EDIT: What's the syntax to build such a class-based enum in Typescript?