-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat(expect, @jest/expect): support type inference for toBe
assertions
#13470
Conversation
toBe
assertions
|
expectType<void>( | ||
expect({name: 'someName', age: 12}).toBe({name: 'someOtherName', age: 13}), | ||
); | ||
expectError(expect({name: 'someName', age: 12}).toBe({name: 'someOtherName'})); |
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.
Hm.. But both of these will fail at run time, right?
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.
yep, both fail at run time
first one passes type checks
second one fails type checks
Changed the inverses to be unknown, I think this is good as this is the current behavior - so it should not do harm |
I see some failing tests in |
Closing because it's a duplicate of #13444 |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
relates to #13334
This is a continuation of #13268, which was merged and reverted in #13339. It adds only one use case that should be safe.
It should improve developer experience by adding type inference for the types passed to the
toBe
assertionTest plan
added automated tests
What do you guys think? @SimenB @mrazauskas