I have a function:
public doSomethingWithEnum(enumType) {
// Iterate over enum keys with Object.keys(enumType)
}
And I can use it like so:
export enum MyEnum { SomeEnumValue = 'SomeEnumValue', SomeOtherValue = 'SomeOtherValue' }
doSomethingWithEnum(MyEnum);
That's fine, it works. The problem is that I'd like a type on that parameter so I can pass it any enum. At the moment, it might aswell be :any
which I think is far too open.
Is there any way of restricting/specifying the type of that parameter?
What I've Tried
I know it's possible to restrict this by listing known types e.g.:
doSomethingWithEnum(enumType: MyEnum | MyOtherEnum)
But I need it more scalable than that, I don't want to have to append a type every time a different consumer needs to call the service.