diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c18240..723291ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog All notable changes to this project will be documented in this file. Dates are displayed in UTC. +## [7.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.0.0...v7.0.1) (2024-05-21) + + +### Bug Fixes + +* handling of partial types ([1832bd0](https://github.com/RebeccaStevens/deepmerge-ts/commit/1832bd071b925c49a2d5d1c944703916ee4348d4)), closes [#476](https://github.com/RebeccaStevens/deepmerge-ts/issues/476) + # [7.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v6.0.3...v7.0.0) (2024-05-20) diff --git a/dist/deno/README.md b/dist/deno/README.md index c0cd28bf..795020ef 100644 --- a/dist/deno/README.md +++ b/dist/deno/README.md @@ -98,7 +98,19 @@ const y = { ]), }; -const merged = deepmerge(x, y); +const z = { + record: { + prop1: undefined, + prop3: undefined, + prop2: undefined, + prop4: undefined, + }, + array: undefined, + set: undefined, + map: undefined, +}; + +const merged = deepmerge(x, y, z); console.log(merged); @@ -109,6 +121,7 @@ console.log(merged); // "prop1": "changed", // "prop2": "value2", // "prop3": "value3", +// "prop4": undefined, // }, // "array": Array [1, 2, 3, 2, 3, 4], // "set": Set { 1, 2, 3, 4 }, diff --git a/dist/deno/types/defaults.ts b/dist/deno/types/defaults.ts index a8096baa..fad23b48 100644 --- a/dist/deno/types/defaults.ts +++ b/dist/deno/types/defaults.ts @@ -55,10 +55,13 @@ export type DeepMergeFunctionsDefaultURIs = Readonly<{ DeepMergeFilterValuesURI: DeepMergeFilterValuesDefaultURI; }>; -type RecordEntries> = TuplifyUnion< - { - [K in keyof T]: [K, T[K]]; - }[keyof T] +type RecordEntries> = FilterOut< + TuplifyUnion< + { + [K in keyof T]: [K, T[K]]; + }[keyof T] + >, + undefined >; type RecordMeta = Record; @@ -79,16 +82,13 @@ type RecordsToRecordMeta< [I in keyof Ts]: RecordToRecordMeta; }>; -type RecordToRecordMeta> = - object extends T - ? never - : { - [K in keyof T]-?: { - key: K; - value: Required[K]; - optional: KeyIsOptional; - }; - }; +type RecordToRecordMeta> = { + [K in keyof T]-?: { + key: K; + value: Required[K]; + optional: KeyIsOptional; + }; +}; /** * Deep merge records. @@ -119,9 +119,16 @@ type DeepMergeRecordMetaDefaultHKTProps< type MergeRecordMeta> = GroupValuesByKey< FlattenTuples< - TransposeTuple<{ - [I in keyof RecordMetas]: TransposeTuple>; - }> + TransposeTuple< + FilterOut< + { + [I in keyof RecordMetas]: TransposeTuple< + RecordEntries + >; + }, + readonly [] + > + > > >; diff --git a/dist/node/index.d.cts b/dist/node/index.d.cts index ce5894d3..6b1ddd24 100644 --- a/dist/node/index.d.cts +++ b/dist/node/index.d.cts @@ -390,12 +390,12 @@ type DeepMergeFunctionsDefaultURIs = Readonly<{ DeepMergeOthersURI: DeepMergeLeafURI; DeepMergeFilterValuesURI: DeepMergeFilterValuesDefaultURI; }>; -type RecordEntries> = TuplifyUnion<{ +type RecordEntries> = FilterOut; +}[keyof T]>, undefined>; type RecordMeta = Record; type RecordPropertyMeta = { key: Key; @@ -405,7 +405,7 @@ type RecordPropertyMeta>> = FilterOutNever<{ [I in keyof Ts]: RecordToRecordMeta; }>; -type RecordToRecordMeta> = object extends T ? never : { +type RecordToRecordMeta> = { [K in keyof T]-?: { key: K; value: Required[K]; @@ -420,9 +420,10 @@ type DeepMergeRecordsDefaultHKT, Fs extends De * Deep merge record props. */ type DeepMergeRecordMetaDefaultHKTProps = RecordMetas extends ReadonlyArray ? CreateRecordFromMeta, Fs, M> : never; -type MergeRecordMeta> = GroupValuesByKey> = GroupValuesByKey>; -}>>>; +}, readonly [ +]>>>>; type GroupValuesByKey = Ts extends readonly [ infer Keys extends ReadonlyArray, infer Values diff --git a/dist/node/index.d.mts b/dist/node/index.d.mts index ce5894d3..6b1ddd24 100644 --- a/dist/node/index.d.mts +++ b/dist/node/index.d.mts @@ -390,12 +390,12 @@ type DeepMergeFunctionsDefaultURIs = Readonly<{ DeepMergeOthersURI: DeepMergeLeafURI; DeepMergeFilterValuesURI: DeepMergeFilterValuesDefaultURI; }>; -type RecordEntries> = TuplifyUnion<{ +type RecordEntries> = FilterOut; +}[keyof T]>, undefined>; type RecordMeta = Record; type RecordPropertyMeta = { key: Key; @@ -405,7 +405,7 @@ type RecordPropertyMeta>> = FilterOutNever<{ [I in keyof Ts]: RecordToRecordMeta; }>; -type RecordToRecordMeta> = object extends T ? never : { +type RecordToRecordMeta> = { [K in keyof T]-?: { key: K; value: Required[K]; @@ -420,9 +420,10 @@ type DeepMergeRecordsDefaultHKT, Fs extends De * Deep merge record props. */ type DeepMergeRecordMetaDefaultHKTProps = RecordMetas extends ReadonlyArray ? CreateRecordFromMeta, Fs, M> : never; -type MergeRecordMeta> = GroupValuesByKey> = GroupValuesByKey>; -}>>>; +}, readonly [ +]>>>>; type GroupValuesByKey = Ts extends readonly [ infer Keys extends ReadonlyArray, infer Values