KeysOfUnion extracts the union of keys from a given union of object types. This is useful in scenarios where you need to access all possible keys across unioned object types within conditional or mapped types.
KeysOfUnion
The union of object types to extract keys from.
type UnionKeys = KeysOfUnion<{ a: string } | { b: number }>; // Result: 'a' | 'b' Copy
type UnionKeys = KeysOfUnion<{ a: string } | { b: number }>; // Result: 'a' | 'b'
KeysOfUnionextracts the union of keys from a given union of object types. This is useful in scenarios where you need to access all possible keys across unioned object types within conditional or mapped types.