import { isArray , mergeWith } from "lodash" ; import { DeepPartial } from "coral-common/types" ; function mergeCopyArrays ( objValue , srcValue ) { if ( isArray ( objValue ) ) { return srcValue ; } } export default function pureMerge < TSource1 , TSource2 > ( source1 , source2 ) ; export default function pureMerge < TSource1 , TSource2 , TSource3 > ( source1 , source2 , source3 ) ; export default function pureMerge < TSource1 , TSource2 , TSource3 , TSource4 > ( source1 , source2 , source3 , source4 ) ; export default function pureMerge < T > ( source , ... partials ) ; /**
 * pureMerge merges given sources into one and returns it
 * as a new object without modifiyng existing ones.
 *
 * You can pass a single type e.g. `pureMerge<MyType>()` then
 * the first argument must match the type fully while the other
 * should match it partially.
 *
 * You can also pass types for each of the arguments.
 */ export default function pureMerge ( ... sources ) { return mergeWith ( { } , ... sources , mergeCopyArrays ) ; }