From 69f2fa11f946aa56805c15684b5305ebeac1062d Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 20 Mar 2023 18:52:37 +1300 Subject: [PATCH] feat: allow restricting what types can be passed in as parameters BREAKING CHANGE: The order of the generics of `deepmergeCustom` and `deepmergeIntoCustom` have changed. If you are passing generics to these functions you need to update them. --- docs/deepmergeCustom.md | 52 ++++++- src/deepmerge-into.ts | 12 +- src/deepmerge.ts | 15 +- tests/deepmerge-custom.test.ts | 57 +++++--- tests/deepmerge-into-custom.test.ts | 7 +- types-legacy/v4_6.d.ts | 214 ++++++++++++++++++++++------ 6 files changed, 274 insertions(+), 83 deletions(-) diff --git a/docs/deepmergeCustom.md b/docs/deepmergeCustom.md index 40d445f4..c3850303 100644 --- a/docs/deepmergeCustom.md +++ b/docs/deepmergeCustom.md @@ -93,6 +93,38 @@ const customizedDeepmerge = deepmergeCustom({ }); ``` +## Restricting the Parameter Types + +By default, anything can be passed into a deepmerge function. +If your custom version relies on certain input types, you can restrict the parameters that can be passed. +This is done with the first generic that can be passed into `deepmergeCustom`. + +For example: + +```ts +import { deepmergeCustom } from "deepmerge-ts"; + +type Foo = { + foo: { + bar: string; + baz?: number; + }; +}; + +const customDeepmerge = deepmergeCustom< + Foo // <-- Only parameters of type Foo to be passed into the function. +>({}); + +const x = { foo: { bar: "bar-1", baz: 3 } }; +const y = { foo: { bar: "bar-2" } }; + +customDeepmerge(x, y); // => { foo: { bar: "bar-2", baz: 3 } } + +const z = { bar: "bar" }; + +customDeepmerge(x, z); // Argument of type '{ bar: string; }' is not assignable to parameter of type 'Foo'. +``` + ## Customizing the Return Type If you want to customize the deepmerge function, you probably also want the return type of the result to be correct too.\ @@ -108,9 +140,12 @@ Here's a simple example that creates a custom deepmerge function that does not m import type { DeepMergeLeafURI } from "deepmerge-ts"; import { deepmergeCustom } from "deepmerge-ts"; -const customDeepmerge = deepmergeCustom<{ - DeepMergeArraysURI: DeepMergeLeafURI; // <-- Needed for correct output type. -}>({ +const customDeepmerge = deepmergeCustom< + unknown, // <-- Types that can be passed into the function. + { + DeepMergeArraysURI: DeepMergeLeafURI; // <-- Needed for correct output type. + } +>({ mergeArrays: false, }); @@ -140,9 +175,12 @@ Here's an example of creating a custom deepmerge function that amalgamates dates import type { DeepMergeLeaf, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionsURIs } from "deepmerge-ts"; import { deepmergeCustom } from "deepmerge-ts"; -const customizedDeepmerge = deepmergeCustom<{ - DeepMergeOthersURI: "MyDeepMergeDatesURI"; // <-- Needed for correct output type. -}>({ +const customizedDeepmerge = deepmergeCustom< + unknown, // <-- Types that can be passed into the function. + { + DeepMergeOthersURI: "MyDeepMergeDatesURI"; // <-- Needed for correct output type. + } +>({ mergeOthers: (values, utils, meta) => { // If every value is a date, the return the amalgamated array. if (values.every((value) => value instanceof Date)) { @@ -232,6 +270,8 @@ import type { DeepMergeLeaf, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunc import { deepmergeCustom } from "deepmerge-ts"; const customizedDeepmerge = deepmergeCustom< + // Allow any value to be passed into the function. + unknown, // Change the return type of `mergeOthers`. { DeepMergeOthersURI: "KeyPathBasedMerge"; diff --git a/src/deepmerge-into.ts b/src/deepmerge-into.ts index c63d495e..3ddf0492 100644 --- a/src/deepmerge-into.ts +++ b/src/deepmerge-into.ts @@ -66,12 +66,12 @@ export function deepmergeInto< * * @param options - The options on how to customize the merge function. */ -export function deepmergeIntoCustom( +export function deepmergeIntoCustom( options: DeepMergeIntoOptions< DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData > -): >( +): >( target: Target, ...objects: Ts ) => void; @@ -83,23 +83,25 @@ export function deepmergeIntoCustom( * @param rootMetaData - The meta data passed to the root items' being merged. */ export function deepmergeIntoCustom< - MetaData, + BaseTs = unknown, + MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData >( options: DeepMergeIntoOptions, rootMetaData?: MetaData -): >( +): >( target: Target, ...objects: Ts ) => void; export function deepmergeIntoCustom< + BaseTs, MetaData, MetaMetaData extends DeepMergeBuiltInMetaData >( options: DeepMergeIntoOptions, rootMetaData?: MetaData -): >( +): >( target: Target, ...objects: Ts ) => void { diff --git a/src/deepmerge.ts b/src/deepmerge.ts index 747a20e2..e6bb56e8 100644 --- a/src/deepmerge.ts +++ b/src/deepmerge.ts @@ -38,10 +38,11 @@ export function deepmerge>>( * @param options - The options on how to customize the merge function. */ export function deepmergeCustom< - PMF extends Partial + BaseTs = unknown, + PMF extends Partial = {} >( options: DeepMergeOptions -): >( +): >( ...objects: Ts ) => DeepMergeHKT< Ts, @@ -56,24 +57,26 @@ export function deepmergeCustom< * @param rootMetaData - The meta data passed to the root items' being merged. */ export function deepmergeCustom< - PMF extends Partial, - MetaData, + BaseTs = unknown, + PMF extends Partial = {}, + MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData >( options: DeepMergeOptions, rootMetaData?: MetaData -): >( +): >( ...objects: Ts ) => DeepMergeHKT, MetaData>; export function deepmergeCustom< + BaseTs, PMF extends Partial, MetaData, MetaMetaData extends DeepMergeBuiltInMetaData >( options: DeepMergeOptions, rootMetaData?: MetaData -): >( +): >( ...objects: Ts ) => DeepMergeHKT, MetaData> { /** diff --git a/tests/deepmerge-custom.test.ts b/tests/deepmerge-custom.test.ts index 3485ac90..1399b9bf 100644 --- a/tests/deepmerge-custom.test.ts +++ b/tests/deepmerge-custom.test.ts @@ -74,9 +74,12 @@ test("custom merge arrays", (t) => { foo: { bar: { baz: { qux: ["1a", "2b", "3c"] } } }, }; - const customizedDeepmerge = deepmergeCustom<{ - DeepMergeArraysURI: "CustomArrays1"; - }>({ + const customizedDeepmerge = deepmergeCustom< + unknown, + { + DeepMergeArraysURI: "CustomArrays1"; + } + >({ mergeArrays: (arrays) => { const maxLength = Math.max(...arrays.map((array) => array.length)); @@ -140,10 +143,13 @@ test("custom merge arrays of records", (t) => { ], }; - const customizedDeepmerge = deepmergeCustom<{ - DeepMergeArraysURI: "CustomArrays2"; - DeepMergeOthersURI: "CustomOthers2"; - }>({ + const customizedDeepmerge = deepmergeCustom< + unknown, + { + DeepMergeArraysURI: "CustomArrays2"; + DeepMergeOthersURI: "CustomOthers2"; + } + >({ mergeArrays: (arrays, utils) => { const maxLength = Math.max(...arrays.map((array) => array.length)); const result: unknown[] = []; @@ -214,9 +220,12 @@ test("custom merge records", (t) => { ], ]; - const customizedDeepmerge = deepmergeCustom<{ - DeepMergeRecordsURI: "CustomRecords3"; - }>({ + const customizedDeepmerge = deepmergeCustom< + unknown, + { + DeepMergeRecordsURI: "CustomRecords3"; + } + >({ mergeRecords: (records, utils, meta) => Object.entries( utils.defaultMergeFunctions.mergeRecords(records, utils, meta) @@ -246,9 +255,12 @@ test("custom don't merge arrays", (t) => { const expected = { foo: [7, 8] } as const; - const customizedDeepmerge = deepmergeCustom<{ - DeepMergeArraysURI: DeepMergeLeafURI; - }>({ + const customizedDeepmerge = deepmergeCustom< + unknown, + { + DeepMergeArraysURI: DeepMergeLeafURI; + } + >({ mergeArrays: false, }); @@ -282,9 +294,12 @@ test("custom merge dates", (t) => { const expected = { foo: [x.foo, y.foo, z.foo] } as const; - const customizedDeepmerge = deepmergeCustom<{ - DeepMergeOthersURI: "MergeDates1"; - }>({ + const customizedDeepmerge = deepmergeCustom< + unknown, + { + DeepMergeOthersURI: "MergeDates1"; + } + >({ mergeOthers: (values, utils) => { if (values.every((value) => value instanceof Date)) { return values; @@ -364,6 +379,7 @@ test("key path based merging", (t) => { }; const customizedDeepmerge = deepmergeCustom< + unknown, { DeepMergeOthersURI: "KeyPathBasedMerge"; }, @@ -711,9 +727,12 @@ test("merging class object as record", (t) => { foo: false, }; - const customizedDeepmerge = deepmergeCustom<{ - DeepMergeOthersURI: "CustomOthers3"; - }>({ + const customizedDeepmerge = deepmergeCustom< + unknown, + { + DeepMergeOthersURI: "CustomOthers3"; + } + >({ mergeOthers: (values, utils, meta) => { let m_allRecords = true; const records = values.map((v) => { diff --git a/tests/deepmerge-into-custom.test.ts b/tests/deepmerge-into-custom.test.ts index 3f9e4421..5d3eda5a 100644 --- a/tests/deepmerge-into-custom.test.ts +++ b/tests/deepmerge-into-custom.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import test from "ava"; import _ from "lodash"; @@ -280,7 +280,10 @@ test("key path based merging", (t) => { bar: { baz: "special merge", qux: 9 }, }; - const customizedDeepmerge = deepmergeIntoCustom>({ + const customizedDeepmerge = deepmergeIntoCustom< + unknown, + ReadonlyArray + >({ metaDataUpdater: (previousMeta, metaMeta) => { if (metaMeta.key === undefined) { return previousMeta ?? []; diff --git a/types-legacy/v4_6.d.ts b/types-legacy/v4_6.d.ts index 6738d013..92b878e2 100644 --- a/types-legacy/v4_6.d.ts +++ b/types-legacy/v4_6.d.ts @@ -2,7 +2,7 @@ * Flatten a complex type such as a union or intersection of objects into a * single object. */ -declare type FlatternAlias = { +declare type FlatternAlias = Is extends true ? T : { [P in keyof T]: T[P]; } & {}; /** @@ -269,10 +269,13 @@ declare type DeepMergeRecordsDefaultHKTInternalPropValue], K extends PropertyKey, M, Acc extends ReadonlyArray> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly> ? Rest extends readonly [unknown, ...ReadonlyArray] ? DeepMergeRecordsDefaultHKTInternalPropValueHelper], K extends PropertyKey, M, Acc extends ReadonlyArray> = Ts extends readonly [ + infer Head extends Readonly>, + ...infer Rest +] ? Rest extends readonly [unknown, ...ReadonlyArray] ? DeepMergeRecordsDefaultHKTInternalPropValueHelper -]> : [...Acc, ValueOfKey] : never : never; +]> : [...Acc, ValueOfKey] : never; /** * Deep merge 2 arrays. */ @@ -280,10 +283,13 @@ declare type DeepMergeArraysDefaultHKT, MF ext /** * Tail-recursive helper type for DeepMergeArraysDefaultHKT. */ -declare type DeepMergeArraysDefaultHKTHelper, MF extends DeepMergeMergeFunctionsURIs, M, Acc extends ReadonlyArray> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends ReadonlyArray ? Rest extends readonly [ +declare type DeepMergeArraysDefaultHKTHelper, MF extends DeepMergeMergeFunctionsURIs, M, Acc extends ReadonlyArray> = Ts extends readonly [ + infer Head extends ReadonlyArray, + ...infer Rest +] ? Rest extends readonly [ ReadonlyArray, ...ReadonlyArray> -] ? DeepMergeArraysDefaultHKTHelper : [...Acc, ...Head] : never : never; +] ? DeepMergeArraysDefaultHKTHelper : [...Acc, ...Head] : never; /** * Deep merge 2 sets. */ @@ -303,15 +309,101 @@ declare type GetDeepMergeMergeFunctionsURIs ? PMF["DeepMergeOthersURI"] : DeepMergeLeafURI; }>; +/** + * The default merge functions. + */ +declare type MergeFunctions$1 = { + mergeRecords: typeof mergeRecords$1; + mergeArrays: typeof mergeArrays$1; + mergeSets: typeof mergeSets$1; + mergeMaps: typeof mergeMaps$1; + mergeOthers: typeof mergeOthers$1; +}; +/** + * The default strategy to merge records into a target record. + * + * @param m_target - The result will be mutated into this record + * @param values - The records (including the target's value if there is one). + */ +declare function mergeRecords$1>, U extends DeepMergeMergeIntoFunctionUtils, M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(m_target: Reference>, values: Ts, utils: U, meta: M | undefined): void; +/** + * The default strategy to merge arrays into a target array. + * + * @param m_target - The result will be mutated into this array + * @param values - The arrays (including the target's value if there is one). + */ +declare function mergeArrays$1>>(m_target: Reference, values: Ts): void; +/** + * The default strategy to merge sets into a target set. + * + * @param m_target - The result will be mutated into this set + * @param values - The sets (including the target's value if there is one). + */ +declare function mergeSets$1>>>(m_target: Reference>, values: Ts): void; +/** + * The default strategy to merge maps into a target map. + * + * @param m_target - The result will be mutated into this map + * @param values - The maps (including the target's value if there is one). + */ +declare function mergeMaps$1>>>(m_target: Reference>, values: Ts): void; +/** + * Set the target to the last value. + */ +declare function mergeOthers$1>(m_target: Reference, values: Ts): void; + +/** + * The default merge functions. + */ +declare type MergeFunctions = { + mergeRecords: typeof mergeRecords; + mergeArrays: typeof mergeArrays; + mergeSets: typeof mergeSets; + mergeMaps: typeof mergeMaps; + mergeOthers: typeof mergeOthers; +}; +/** + * The default strategy to merge records. + * + * @param values - The records. + */ +declare function mergeRecords>, U extends DeepMergeMergeFunctionUtils, MF extends DeepMergeMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT; +/** + * The default strategy to merge arrays. + * + * @param values - The arrays. + */ +declare function mergeArrays>, MF extends DeepMergeMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT; +/** + * The default strategy to merge sets. + * + * @param values - The sets. + */ +declare function mergeSets>>>(values: Ts): DeepMergeSetsDefaultHKT; +/** + * The default strategy to merge maps. + * + * @param values - The maps. + */ +declare function mergeMaps>>>(values: Ts): DeepMergeMapsDefaultHKT; +/** + * Get the last value in the given array. + */ +declare function mergeOthers>(values: Ts): unknown; + /** * The options the user can pass to customize deepmerge. */ -declare type DeepMergeOptions> = DeepMergeBuiltInMetaData> = Partial>; -declare type MetaDataUpdater = (previousMeta: M | undefined, metaMeta: Readonly>) => M; +declare type DeepMergeOptions> = {}> = Partial>; +/** + * The options the user can pass to customize deepmergeInto. + */ +declare type DeepMergeIntoOptions> = {}> = Partial>; +declare type MetaDataUpdater = (previousMeta: M | undefined, metaMeta: Readonly>) => M; /** * All the options the user can pass to customize deepmerge. */ -declare type DeepMergeOptionsFull = Readonly<{ +declare type DeepMergeOptionsFull = Readonly<{ mergeRecords: DeepMergeMergeFunctions["mergeRecords"] | false; mergeArrays: DeepMergeMergeFunctions["mergeArrays"] | false; mergeMaps: DeepMergeMergeFunctions["mergeMaps"] | false; @@ -320,22 +412,50 @@ declare type DeepMergeOptionsFull = Read metaDataUpdater: MetaDataUpdater; enableImplicitDefaultMerging: boolean; }>; +/** + * All the options the user can pass to customize deepmergeInto. + */ +declare type DeepMergeIntoOptionsFull = Readonly<{ + mergeRecords: DeepMergeMergeIntoFunctions["mergeRecords"] | false; + mergeArrays: DeepMergeMergeIntoFunctions["mergeArrays"] | false; + mergeMaps: DeepMergeMergeIntoFunctions["mergeMaps"] | false; + mergeSets: DeepMergeMergeIntoFunctions["mergeSets"] | false; + mergeOthers: DeepMergeMergeIntoFunctions["mergeOthers"]; + metaDataUpdater: MetaDataUpdater; +}>; +/** + * An object that has a reference to a value. + */ +declare type Reference = { + value: T; +}; +/** + * All the merge functions that deepmerge uses. + */ +declare type DeepMergeMergeFunctions = Readonly<{ + mergeRecords: >>, U extends DeepMergeMergeFunctionUtils>(values: Ts, utils: U, meta: M | undefined) => unknown; + mergeArrays: >, U extends DeepMergeMergeFunctionUtils>(values: Ts, utils: U, meta: M | undefined) => unknown; + mergeMaps: >>, U extends DeepMergeMergeFunctionUtils>(values: Ts, utils: U, meta: M | undefined) => unknown; + mergeSets: >>, U extends DeepMergeMergeFunctionUtils>(values: Ts, utils: U, meta: M | undefined) => unknown; + mergeOthers: , U extends DeepMergeMergeFunctionUtils>(values: Ts, utils: U, meta: M | undefined) => unknown; +}>; +declare type DeepMergeMergeIntoFunctionsReturnType = void | symbol; /** * All the merge functions that deepmerge uses. */ -declare type DeepMergeMergeFunctions = Readonly<{ - mergeRecords: >>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: M | undefined) => unknown; - mergeArrays: >, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: M | undefined) => unknown; - mergeMaps: >>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: M | undefined) => unknown; - mergeSets: >>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: M | undefined) => unknown; - mergeOthers: , U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: M | undefined) => unknown; +declare type DeepMergeMergeIntoFunctions = Readonly<{ + mergeRecords: >>, U extends DeepMergeMergeIntoFunctionUtils>(m_target: Reference>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType; + mergeArrays: >, U extends DeepMergeMergeIntoFunctionUtils>(m_target: Reference, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType; + mergeMaps: >>, U extends DeepMergeMergeIntoFunctionUtils>(m_target: Reference>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType; + mergeSets: >>, U extends DeepMergeMergeIntoFunctionUtils>(m_target: Reference>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType; + mergeOthers: , U extends DeepMergeMergeIntoFunctionUtils>(m_target: Reference, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType; }>; /** * The utils provided to the merge functions. */ -declare type DeepMergeMergeFunctionUtils = Readonly<{ +declare type DeepMergeMergeFunctionUtils = Readonly<{ mergeFunctions: DeepMergeMergeFunctions; - defaultMergeFunctions: DeepMergeMergeFunctionsDefaults; + defaultMergeFunctions: MergeFunctions; metaDataUpdater: MetaDataUpdater; deepmerge: >(...values: Ts) => unknown; useImplicitDefaultMerging: boolean; @@ -344,18 +464,19 @@ declare type DeepMergeMergeFunctionUtils skip: symbol; }>; }>; - -declare const defaultMergeFunctions: { - readonly mergeMaps: typeof defaultMergeMaps; - readonly mergeSets: typeof defaultMergeSets; - readonly mergeArrays: typeof defaultMergeArrays; - readonly mergeRecords: typeof defaultMergeRecords; - readonly mergeOthers: typeof leaf; -}; /** - * The default merge functions. + * The utils provided to the merge functions. */ -declare type DeepMergeMergeFunctionsDefaults = typeof defaultMergeFunctions; +declare type DeepMergeMergeIntoFunctionUtils = Readonly<{ + mergeFunctions: DeepMergeMergeIntoFunctions; + defaultMergeFunctions: MergeFunctions$1; + metaDataUpdater: MetaDataUpdater; + deepmergeInto: >(target: Target, ...values: Ts) => void; + actions: Readonly<{ + defaultMerge: symbol; + }>; +}>; + /** * Deeply merge objects. * @@ -367,41 +488,44 @@ declare function deepmerge>>(...objec * * @param options - The options on how to customize the merge function. */ -declare function deepmergeCustom>(options: DeepMergeOptions): >(...objects: Ts) => DeepMergeHKT, DeepMergeBuiltInMetaData>; +declare function deepmergeCustom = {}>(options: DeepMergeOptions): >(...objects: Ts) => DeepMergeHKT, DeepMergeBuiltInMetaData>; /** * Deeply merge two or more objects using the given options and meta data. * * @param options - The options on how to customize the merge function. * @param rootMetaData - The meta data passed to the root items' being merged. */ -declare function deepmergeCustom, MetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions, rootMetaData?: MetaData): >(...objects: Ts) => DeepMergeHKT, MetaData>; +declare function deepmergeCustom = {}, MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions, rootMetaData?: MetaData): >(...objects: Ts) => DeepMergeHKT, MetaData>; + /** - * The default strategy to merge records. + * Deeply merge objects into a target. * - * @param values - The records. + * @param target - This object will be mutated with the merge result. + * @param objects - The objects to merge into the target. */ -declare function defaultMergeRecords>, U extends DeepMergeMergeFunctionUtils, MF extends DeepMergeMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT; +declare function deepmergeInto(target: T, ...objects: ReadonlyArray): void; /** - * The default strategy to merge arrays. + * Deeply merge objects into a target. * - * @param values - The arrays. + * @param target - This object will be mutated with the merge result. + * @param objects - The objects to merge into the target. */ -declare function defaultMergeArrays>, MF extends DeepMergeMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT; +declare function deepmergeInto>(target: Target, ...objects: Ts): asserts target is FlatternAlias>; /** - * The default strategy to merge sets. + * Deeply merge two or more objects using the given options. * - * @param values - The sets. + * @param options - The options on how to customize the merge function. */ -declare function defaultMergeSets>>>(values: Ts): DeepMergeSetsDefaultHKT; +declare function deepmergeIntoCustom(options: DeepMergeIntoOptions): >(target: Target, ...objects: Ts) => void; /** - * The default strategy to merge maps. + * Deeply merge two or more objects using the given options and meta data. * - * @param values - The maps. - */ -declare function defaultMergeMaps>>>(values: Ts): DeepMergeMapsDefaultHKT; -/** - * Get the last value in the given array. + * @param options - The options on how to customize the merge function. + * @param rootMetaData - The meta data passed to the root items' being merged. */ -declare function leaf>(values: Ts): unknown; +declare function deepmergeIntoCustom(options: DeepMergeIntoOptions, rootMetaData?: MetaData): >(target: Target, ...objects: Ts) => void; -export { DeepMergeArraysDefaultHKT, DeepMergeBuiltInMetaData, DeepMergeHKT, DeepMergeLeaf, DeepMergeLeafHKT, DeepMergeLeafURI, DeepMergeMapsDefaultHKT, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionUtils, DeepMergeMergeFunctionsDefaultURIs, DeepMergeMergeFunctionsDefaults, DeepMergeMergeFunctionsURIs, DeepMergeOptions, DeepMergeRecordsDefaultHKT, DeepMergeSetsDefaultHKT, deepmerge, deepmergeCustom }; +export { DeepMergeArraysDefaultHKT, DeepMergeBuiltInMetaData, DeepMergeHKT, DeepMergeIntoOptions, DeepMergeLeaf, DeepMergeLeafHKT, DeepMergeLeafURI, DeepMergeMapsDefaultHKT, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionUtils, DeepMergeMergeFunctionsDefaultURIs, MergeFunctions as DeepMergeMergeFunctionsDefaults, DeepMergeMergeFunctionsURIs, DeepMergeMergeIntoFunctionUtils, MergeFunctions$1 as DeepMergeMergeIntoFunctionsDefaults, DeepMergeOptions, DeepMergeRecordsDefaultHKT, DeepMergeSetsDefaultHKT, Reference as DeepMergeValueReference, deepmerge, deepmergeCustom, deepmergeInto, deepmergeIntoCustom };