Options
All
  • Public
  • Public/Protected
  • All
Menu

Type aliases

Type aliases

Merge

Merge<O, O1, depth, ignore, fill>: object[depth]

Accurately merge the fields of O with the ones of O1. It is equivalent to the spread operator in JavaScript. [[Union]]s and Optional fields will be handled gracefully.

(⚠️ needs --strictNullChecks enabled)

Type parameters

  • O: object

    to complete

  • O1: object

    to copy from

  • depth: Depth

    (?='flat') 'deep' to do it deeply

  • ignore: object

    (?=BuiltIn) types not to merge

  • fill: any

    (?=undefined) types of O to be replaced with ones of O1

returns

Object

example

import {O} from 'ts-toolbelt'

type O = {
 name?: string
 age? : number
 zip? : string
 pay  : {
     cvv?: number
 }
}

type O1 = {
 age : number
 zip?: number
 city: string
 pay : {
     cvv : number
     ccn?: string
 }
}

type test = O.Merge<O, O1, 'deep'>
// {
//     name?: string;
//     age: number;
//     zip?: string | number;
//     pay: {
//         cvv: number;
//         ccn?: string;
//     };
//     city: 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.