Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(DeepMergeAllFn): refine DeepMergeAllFn return type when handling lists with deep partial objects #64

Conversation

simonepizzamiglio
Copy link
Contributor

Summary

This PR fixes an issue in the DeepMergeAllFn type where the returned type did not correctly match the type of the first object in scenarios where a list of objects was passed, and the subsequent objects were deep partial versions of the first.

Problem

Previously, when DeepMergeAllFn was called with a list of objects, where all objects from the second onward were deep partial versions of the first object, the return type defaulted to DeepMergeAll<{}, T> instead of preserving the type of the first object. This led to incorrect typings and made the function’s behavior less predictable.

The screenshot below shows the error before the changes in this PR: the deepmerge function would return a partial object type.
Screenshot 2025-01-17 at 16 18 30

Checklist

@simonepizzamiglio
Copy link
Contributor Author

The AllDeepPartialOrSame type does not handle cases where, starting from the second element onward, a non-deep partial version of the first item is passed. This happens because the condition Rest extends { [index: number]: DeepPartial<First> } would evaluate to true, even in such scenarios.

Closing because this is not feasible due to TS constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant