Let’s say I have an enum like this:
enum MyServices {
ServiceOne = "Service One",
ServiceTwo = "Service Two"
}
and I need to have a type which should allow to make the following:
type EnrichEnum<Type> = { ... };
const enrichedValue: EnrichEnum<MyServices> = {
"Service One": MyServices.ServiceOne, // --> any values from MyServices, correlated
MyServices.ServiceOne: "Service One", // --> any values from MyServices, correlated
payload: string
};
but the properties must relate correctly. Meaning, this would be incorrect:
const wrong1: EnrichEnum<MyServices> = {
"Service One": MyServices.ServiceTwo, // <=>
MyServices.ServiceOne: "Service One",
payload: string
};
const wrong2: EnrichEnum<MyServices> = {
"Service One": MyServices.ServiceOne,
MyServices.ServiceTwo: "Service One", // <=>
payload: string
};
Hopefully, this is clear…
Unfortunately, I tried multiple times and I can’t do it.