Skip to content

Instantly share code, notes, and snippets.

@Aaronius
Last active June 28, 2022 09:52
Show Gist options
  • Save Aaronius/7d476cb4f906b4892c453a76fe4cc285 to your computer and use it in GitHub Desktop.
Save Aaronius/7d476cb4f906b4892c453a76fe4cc285 to your computer and use it in GitHub Desktop.
CombineObjectsFromTuple
type Combine<A, B> = Omit<A, keyof B> &
Omit<B, keyof A> & { [K in keyof A & keyof B]: A[K] | B[K] };
type CombineObjectsFromTuple<T> = T extends [infer K, ...infer R]
? Combine<K, CombineObjectsFromUnion<R>>
: T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment