Type alias OmitCommonKeys<T, U>

OmitCommonKeys<T, U>: Pick<T, Exclude<Keys<T>, Keys<U>>>

Omit the common keys between the the two objects,

Type Parameters

  • T extends Record<string, unknown>
  • U extends Record<string, unknown>

Returns

An object that consist of what's unique in both, else never

Example

OmitCommonKeys<{ d: { d: 'a' }; p: { b: 'b' }; x: { c: 'c' } }, { d: 'd' }>
// Result:
{
p: {
b: 'b';
};
x: {
c: 'c';
};
}

OmitCommonKeys<
{ d: 'd'; k: 'k' },
{ d: 'd'; p: { b: 'b' }; x: { c: 'c' } }
>
// Result:
{ k: 'k' }