Is it possible to get the values of an enum in TypeScript as an array?
Like this:
enum MyEnum {
FOO = 'foo',
BAR = 'bar'
}
becomes
['foo', 'bar']
Yes, it is possible to use:
Object.values(MyEnum)
because enum is an JS object after compilation:
var MyEnum;
(function (MyEnum) {
MyEnum["FOO"] = "foo";
MyEnum["BAR"] = "bar";
})(MyEnum || (MyEnum = {}));