import _ from "lodash"; const nilMerge = (a: any, b: any): any => (_.isNil(a) ? b : a); const nilMergeDeep = (a: any, b: any): any => _.isObject(a) && !_.isArray(a) ? // recursively merge objects with nilMergeDeep customizer _.mergeWith({}, a, b, nilMergeDeep) : // use default customizer nilMerge(a, b); export default nilMergeDeep;