@cuppachino/type-space
Version:
A collection of type utilities for TypeScript.
11 lines (10 loc) • 500 B
TypeScript
import type { OmitExactOptionalUndefined } from './exclue-exact-optional-undefined';
import type { Primitive } from './primitive';
/**
* Deeply merges a tuple of objects from right to left.
*
* @example
*/
export type DeepMergeRight<A, B> = OmitExactOptionalUndefined<{
[K in keyof A | keyof B]: (K extends keyof B ? B[K] : A[Extract<K, keyof A>]) extends infer V extends Primitive ? V : K extends keyof A ? K extends keyof B ? DeepMergeRight<A[K], B[K]> : A[K] : B[Extract<K, keyof B>];
}>;