Index
Type aliases
Type aliases
Diff
Type parameters
-
O: object
to check differences with
-
O1: object
to check differences against
-
match: Match
to change precision (?=
'default'
)
returns
object
example
import {O} from 'ts-toolbelt'
type Person0 = {
name: string
age: string
}
type Person1 = {
name: string
age: number | string
nick: string
}
type test0 = O.Diff<Person0, Person1, 'default'> // {nick: string}
type test1 = O.Diff<Person0, Person1, 'extends->'> // {nick: string; age: string | number}
type test2 = O.Diff<Person0, Person1, '<-extends'> // {nick: string; age: string}
type test3 = O.Diff<Person0, Person1, 'equals'> // {nick: string; age: string}
Get an
object
that is the difference betweenO
&O1
(O
's differences have priority overO1
's if fields overlap) (Ifmatch = 'default'
, no type checks are done)