-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
[jest] fix type inference for Mocked & mockResolvedValue/mockRejectedValue #32816
[jest] fix type inference for Mocked & mockResolvedValue/mockRejectedValue #32816
Conversation
@Chris-V updated code to be consistent with mockImplementation() & added tests |
@antoinebrault Thank you for submitting this PR! 🔔 @NoHomey @jwbay @asvetliakov @alexjoverm @epicallan @ikatyang @wsmd @JamieMason @douglasduteil @ahnpnl @JoshuaKGoldberg @UselessPickles @r3nya @Hotell @sebald @andys8 @aldentaylor - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
Thank you! We had several helpers types in our code base to improve type-safety with jest. This will help us get rid of most of them! |
I provided an alternative proposal to solve this issue just for consideration, see #32898 - Please feel free to close this PR if you prefer your own solution. :-) |
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.
Proposal to add additional tests + (optional) proposal to introduce correct (i.e. more strongly typed) signature for jest.fn, Mock, etc. Feel free to go along w/o the proposed changes if you think I'm off track. :-)
@antoinebrault Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day! |
🔔 @Jerico-Dev @jwbay - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate? |
🔔 @jwbay - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate? |
A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped! |
# Conflicts: # types/jest/index.d.ts
…roperties & spyOn method to function properties
I just published |
I just published |
Follow-up of #32579 (comment) , fixes #32890
Fixed Mocked interface & mockResolvedValue/mockRejectedValue
Breaking Change
With types inferred, mockResolvedValue(), mockRejectedValue() will not compile if they are used on a function not returning a Promise.
e.g.
Please fill in this template.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).Select one of these and delete the others:
If changing an existing definition:
tslint.json
containing{ "extends": "dtslint/dt.json" }
.