Is it possible to merge all properties in a discriminated union of object types?
As an example, suppose I have the following type:
type UnionType = { name: string; } | { age: number; } | { visible: boolean; }
Is it possible to then merge these into a single type like this:
// Expect: { name: string; age: number; visible: boolean };
type Props = MagicType<UnionType>;
This is essentially the inverse of the Unionize
type from utility-types
.