I can get all keys of a union by type UnionKeys<T> = { [Key in keyof T]: Key }[keyof T]
type MyUnion = {x: 'a', y: 'b'} | {x: 'aa', z: 'c'}
type T1 = UnionKeys<MyUnion> // 'x' | 'y' | 'z'
How do I get the merged type of a union?
type MergedUnion<T> = ?????
type T2 = MergedUnion<MyUnion> // `{x: 'a' | 'aa', y: 'b', z: 'c'}`