Skip to main content
Module

x/ts_toolbelt_unofficial/mod.ts>O.Diff

👷 TypeScript's largest type utility library, now on Deno
Latest
type alias O.Diff
import { type O } from "https://deno.land/x/ts_toolbelt_unofficial@1.1.0/mod.ts";
const { Diff } = O;

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)

Examples

Example 1

import {O} from 'ts-toolbelt.ts'

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}

Type Parameters

O extends object
O1 extends object
optional
match extends Match = "default"
definition: PatchFlat<Exclude<O, O1, match>, Exclude<O1, O, match>>