You can create a function that receives two objects with optional nested properties as argument and merge them recursively, giving precedence to the properties of the first object.
Here is an example implementation:
index.ts829 chars24 linesYou can then use this function like this:
index.ts388 chars31 linesThis will output:
index.ts198 chars16 lines
As you can see, the properties of obj1 are kept, except for the ones that are overwritten by obj2. The nested objects are recursively merged, giving precedence to obj1.
gistlibby LogSnag