-
-
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 function parame… #13268
Merged
Merged
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d447395
feat(expect, jest-expect): support type inference for function parame…
royhadad 7c1f44c
update changlog
royhadad f7d4b18
docs: add pull request link to changlog
royhadad ff002fd
docs: fix typo
royhadad cac0bb1
style: fix prettier
royhadad 4c37edc
Update CHANGELOG.md
royhadad a01e6d8
Merge branch 'facebook:main' into main
royhadad 5860397
try something
royhadad 2c9dac7
wip
royhadad e73f878
remove type param
royhadad 4080950
refactor: use idea from pr #13278
royhadad c87ad1c
use any instead of unknown in EnsureFunctionLike
royhadad f2bfab9
add more tests
royhadad 8969360
remove changlog fixes
royhadad 3bdf5f9
try
royhadad 0655ce0
try
royhadad 8332a60
revert
royhadad e483fa1
test: add test cases for other methods
royhadad b7e41d1
fix test
royhadad 61d3fbc
fix test
royhadad 6b62fe0
Merge branch 'facebook:main' into main
royhadad 07333c1
remove redundant test
royhadad 59bbde0
Merge branch 'facebook:main' into main
royhadad 4b15e90
Update CHANGELOG.md
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -217,6 +217,38 @@ expectType<void>(expect(jest.fn()).toBeCalledWith('value', 123)); | |||
expectType<void>(expect(jest.fn()).toHaveBeenCalledWith()); | ||||
expectType<void>(expect(jest.fn()).toHaveBeenCalledWith(123)); | ||||
expectType<void>(expect(jest.fn()).toHaveBeenCalledWith(123, 'value')); | ||||
expectType<void>(expect(jest.fn()).toHaveBeenCalledWith(123, 'value')); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
same as above, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch! This was not on purpose :) |
||||
|
||||
/** | ||||
* type inference for "CalledWith" matchers parameters | ||||
*/ | ||||
expectError(expect(jest.fn<(a: string) => void>()).toHaveBeenCalledWith(123)); | ||||
expectError( | ||||
expect(jest.fn<(a: string) => void>()).toHaveBeenNthCalledWith(123), | ||||
royhadad marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
); | ||||
expectError( | ||||
expect(jest.fn<(a: string) => void>()).toHaveBeenLastCalledWith(123), | ||||
); | ||||
expectType<void>( | ||||
expect( | ||||
jest.fn<(a: string, b: number, c?: boolean) => void>(), | ||||
).toHaveBeenCalledWith('value', 123), | ||||
); | ||||
expectType<void>( | ||||
expect( | ||||
jest.fn<(a: string, b: number, c?: boolean) => void>(), | ||||
).toHaveBeenCalledWith('value', 123, true), | ||||
); | ||||
expectError( | ||||
expect( | ||||
jest.fn<(a: string, b: number, c?: boolean) => void>(), | ||||
).toHaveBeenCalledWith(123, 'value'), | ||||
); | ||||
expectError( | ||||
expect( | ||||
jest.fn<(a: string, b: number, c?: boolean) => void>(), | ||||
).toHaveBeenCalledWith('value', 123, 'not a boolean'), | ||||
); | ||||
|
||||
expectType<void>(expect(jest.fn()).lastCalledWith()); | ||||
expectType<void>(expect(jest.fn()).lastCalledWith('value')); | ||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Wanna send a separate PR for these to changes? That way CI will trigger when you push without me having to press a button 🙂
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.
I'm not totally sure what you mean, maybe suggest a change?
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.
Extract the removal of
feat
from the changelog to a separate PRThere 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.
I tried doing that and the workflow did not automatically run: 8969360
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.
Yeah, I meant make those changes in a separate PR which I'll merge. Then approval is no longer needed (once you have a merged contribution)
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.
sure