I have a typescript enum MyEnum:
export enum MyEnum {
ALPHA = 'ALPHA',
BETA = 'BETA'
}
I want to use the enum values as properties of another class. I know can do stuff like that:
export class MyClass {
vals: {[key in MyEnum]} = {
ALPHA: true,
BETA: false
}
anotherProp: boolean;
aMethod() {
if (this.vals.ALPHA) doStuff();
}
}
But I'm wondering if it's possible to use the enum values as properties of the class itself, not as properties of one of its nested objects:
export class myClass {
// here be my properties from myEnum. How?
anotherProp: boolean
aMethod() {
if (this.ALPHA) doStuff(); // ALPHA is type checked
}
}
Is that possible?