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

fix: change DeepPartial to account for object union types & unknown #11385

Merged

Conversation

RulerOfCakes
Copy link
Contributor

From the previous enhancement to allow unknown to be compatible with DeepPartial(#11333), it introduced an unintended bug, being incompatible with union types containing both object & non-object types. Although this was resolved in #11373, it again made the definition of DeepPartial incompatible with any types containing unknown again.

With a new proposed definition that should be able to handle such cases, I have added some test cases discovered throughout #11333 and #11373 as type tests along with the new definition. By using ExtractObjects to extract any type that extends object from a potential union type, it successfully applies DeepPartial for such object types while supporting unknown as well.

Copy link

codesandbox bot commented Jan 11, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thanks for the PR and the type tests.

@bluebill1049 bluebill1049 merged commit cec3267 into react-hook-form:master Jan 15, 2024
7 checks passed
@professorkolik
Copy link

This PR breaks types in global watch()

All data become optional

@RulerOfCakes
Copy link
Contributor Author

This PR breaks types in global watch()

All data become optional

I think the issue you're mentioning is related to #11359 🤔

rafaelcalhau pushed a commit to rafaelcalhau/react-hook-form that referenced this pull request May 5, 2024
…nown` (react-hook-form#11385)

* feat: extract objects from DeepPartial check

* chore: api-extractor

* fix: api-extractor build

---------

Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com>
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.

None yet

3 participants