-
-
Notifications
You must be signed in to change notification settings - Fork 158
Open
Labels
runtimeIssues that refer to the runtime behaviorIssues that refer to the runtime behaviortypingSomething type relatedSomething type related
Description
Just discovered Remeda after looking for an alternative to es-toolkit which has some type issues in some cases due to its loose types.
One thing I miss from es-toolkit is its mergeWith utility. Specifically, I use it to deeply merge two objects while concatenating arrays:
import { mergeWith } from "es-toolkit"
mergeWith(target, source, (objValue: unknown, srcValue: unknown) =>
Array.isArray(objValue) ? objValue.concat(srcValue) : undefined,
)The MergeDeep type from type-fest that mergeDeep already returns supports this kind of thing:
MergeDeep<Destination, Source, { arrayMergeMode: "spread" }>.
So my suggestion would be something like mergeDeepConcat instead of an actual mergeWith function, because I'm not sure how you'd be able to handle types correctly in the latter case.
function mergeDeepConcat<Destination extends object, Source extends object>(destination: Destination, source: Source):
MergeDeep<Destination, Source, { arrayMergeMode: "spread" }>Metadata
Metadata
Assignees
Labels
runtimeIssues that refer to the runtime behaviorIssues that refer to the runtime behaviortypingSomething type relatedSomething type related