import { isObject } from './isObject' ; param objTarget param objSource export function mergeObjects < A extends object , B extends object > ( objTarget , objSource ) { for ( const [ key , value ] of Object . entries ( objSource ) ) { const targetValue = Reflect . get ( objTarget , key ) ; if ( isObject ( value ) ) { Reflect . set ( objTarget , key , isObject ( targetValue ) ? mergeObjects ( targetValue , value as object ) : value ) ; } else if ( ! isObject ( targetValue ) ) { Reflect . set ( objTarget , key , value ) ; } } return objTarget as A & B ; }