How to transform union of similar objects to object type using TypeScript typings?
Input
type I = {
key: 'foo',
value: Foo,
} | {
key: 'bar',
value: Bar,
};
Output
type O = {
foo: Foo,
bar: Bar,
};
I am not sure it is possible. But who knows? Note that the task is not a duplicate to that.
O
fromI
? How does that help you?O
is not that hard to type into your code -- you did it above. So yeah, see whether you can improve or clarify the question, I'd say.