utility-types
utility-types copied to clipboard
rfc: add DeepAssign
Is your feature request related to a real problem or use-case?
When I have multiple sources of options that need to be combined, I want to use a deepmerge, but the resulting type is imperfect. That is, there is not currently available a generic type that properly represents a deep merging of objects with non-uniform shape.
This is a common use case exemplified by the 20million d/ls on deepmerge
Example shown in the solution below.
Describe a solution including usage in code example
Who does this impact? Who is this for?
TS users wanting to merge deep objects and get a correct type out.
Describe alternatives you've considered (optional)
- creating explicit types and performing the nested merges manually
- just flattening stuff and avoiding deep merging altogether
- using a DeepPartial, then using something like zod or runtypes to reflect back the deep type at the cost of runtime perf
Additional context (optional)
n/a