I have the following types defined
type MyUnionType = "propA" | "propB"
type MyType = {
myProp: MyUnionType
}
type SomeOtherType = MyType & { ... /* other props*/ ... }
Now, I would like to enhance MyType with something along the lines of
type MyType = {
myProp: MyUnionType,
[key in MyUnionType]: any // pseudo code
}
so that I can use it like this
const obj: SomeOtherType = {
myProp: "propA",
propA: "some value" // if this is missing, compiler will error
[...] // some other props
}
I played around it a little bit, searched the web, but I didn't come up with any solution.
EDIT: I just removed string from MyUnionType as requested