to complete
to copy from
(?='flat'
) 'deep' to do it deeply
(?=BuiltIn
) types not to merge
(?=undefined
) types of O
to be replaced with ones of O1
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;
// }
Accurately merge the fields of
O
with the ones ofO1
. It is equivalent to the spread operator in JavaScript. [[Union]]s and Optional fields will be handled gracefully.(⚠️ needs
--strictNullChecks
enabled)