-
Notifications
You must be signed in to change notification settings - Fork 273
fix: correct type inference for props when initialProps is used #1421
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: correct type inference for props when initialProps is used #1421
Conversation
391b99e
to
da2e542
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pierrezimmermannbam looks good. I've suggested some minor changes based on RTL's typing.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1421 +/- ##
==========================================
+ Coverage 96.88% 96.89% +0.01%
==========================================
Files 65 65
Lines 3693 3705 +12
Branches 538 539 +1
==========================================
+ Hits 3578 3590 +12
Misses 115 115
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let's merge!
This PR has been released in v12.1.3 🚢 |
Summary
Fixes #1420
Because we were using conditionals in RenderHookOptions and the way Typescript works with conditionals, Props type was inferred too strictly. For instance when doing:
Props type would be infered as 5 and not number | undefined which would be the expected type.
This PR fixes this issue by removing the use of the conditional. This doesn't change much the behavior and it aligns with the types from testing library react hooks and react testing library
Test plan
I added a test case to check that the type is inferred correctly