UNPKG

type-plus

Version:
20 lines (16 loc) 767 B
import type { IsEqual } from '../equal/equal.js' import type { AnyRecord } from './AnyRecord.js' import type { IsDisjoint } from './IsDisjoint.js' import type { KeysWithDiffType } from './KeysWithDiffType.js' import type { Properties } from './properties.js' export type ANotB<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true ? never : IsDisjoint<A, B> extends true ? A : { [k in Exclude<keyof A, keyof B> | KeysWithDiffType<A, B>]: A[k] } export type BNotA<A extends AnyRecord, B extends AnyRecord> = ANotB<B, A> export type LeftJoin<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true ? A : IsDisjoint<A, B> extends true ? A & B : Properties<{ [k in Exclude<keyof A, keyof B>]: A[k] } & { [k in keyof B]: B[k] }>