1 | import { Exclude } from './Exclude';
|
2 | import { Match } from '../Any/_Internal';
|
3 | import { PatchFlat } from './Patch';
|
4 | /**
|
5 | * Get an [[Object]] that is the difference between `O` & `O1`
|
6 | * (`O`'s differences have priority over `O1`'s if fields overlap)
|
7 | * (If `match = 'default'`, no type checks are done)
|
8 | * @param O to check differences with
|
9 | * @param O1 to check differences against
|
10 | * @param match (?=`'default'`) to change precision
|
11 | * @returns [[Object]]
|
12 | * @example
|
13 | * ```ts
|
14 | * import {O} from 'ts-toolbelt'
|
15 | *
|
16 | * type Person0 = {
|
17 | * name: string
|
18 | * age: string
|
19 | * }
|
20 | *
|
21 | * type Person1 = {
|
22 | * name: string
|
23 | * age: number | string
|
24 | * nick: string
|
25 | * }
|
26 | *
|
27 | * type test0 = O.Diff<Person0, Person1, 'default'> // {nick: string}
|
28 | * type test1 = O.Diff<Person0, Person1, 'extends->'> // {nick: string; age: string | number}
|
29 | * type test2 = O.Diff<Person0, Person1, '<-extends'> // {nick: string; age: string}
|
30 | * type test3 = O.Diff<Person0, Person1, 'equals'> // {nick: string; age: string}
|
31 | * ```
|
32 | */
|
33 | export declare type Diff<O extends object, O1 extends object, match extends Match = 'default'> = PatchFlat<Exclude<O, O1, match>, Exclude<O1, O, match>>;
|