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

docs: fix one TypeScript example in Mock Functions documentation #12520

Merged
merged 2 commits into from Mar 1, 2022

Conversation

mrazauskas
Copy link
Contributor

Summary

Just noticed that one of the examples in Mock Functions documentation needs to be typed. Here scalar is of type any, because of missing annotation:

const mockFn = jest.fn(scalar => 42 + scalar);

Must be:

const mockFn = jest.fn((scalar: number) => 42 + scalar);

Test plan

Green CI.

@SimenB
Copy link
Member

SimenB commented Mar 1, 2022

Is it possible for scalar to be unknown instead of any?

@SimenB SimenB merged commit 4067c51 into jestjs:main Mar 1, 2022
@mrazauskas mrazauskas deleted the fix-docs-ts-example branch March 1, 2022 08:22
@mrazauskas
Copy link
Contributor Author

Is it possible for scalar to be unknown instead of any?

That’s good question. In a way, scalar implicitly has any and that type is respected, but why TS does not complain with "implicitly has an 'any' type"? I will look at this.

Screenshot 2022-03-01 at 10 40 28

@SimenB
Copy link
Member

SimenB commented Mar 1, 2022

yeah, if TS would complain about implicit any I'd care less. Ideally it'd be implicit unknown, tho 😀

@github-actions
Copy link

github-actions bot commented Apr 1, 2022

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants