I am working with an enum defined as:
enum MyEnum {
key1 = 'val1'
key2 = 'val2'
}
However, I am unsure how to create a SomeType
implementation that fulfills the following requirements:
- Function:
const myFunction = (param: SomeType) => {
...
}
- It should support the following use cases:
myFunction(MyEnum.key1) // <- also accepts enums
myFunction('val1') // <- also accepts values of the enum
myFunction('someOtherValue') // <- Error
P.S. Alternatively, if the keys and values of the enums match, return the keys instead of values.