Options
All
  • Public
  • Public/Protected
  • All
Menu

Type aliases

Type aliases

Diff

Diff<O, O1, match>: PatchFlat<Exclude<O, O1, match>, Exclude<O1, O, match>>

Get an Object that is the difference between O & O1 (O's differences have priority over O1's if fields overlap) (If match = 'default', no type checks are done)

Type parameters

  • O: object

    to check differences with

  • O1: object

    to check differences against

  • match: Match

    (?='default') to change precision

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}

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.