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

refactor(jest-mock): clean up internal typings more #13575

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

mrazauskas
Copy link
Contributor

Summary

The spyOn current is missing a return type. Recent refactors made it possible to add the type and to remove eslint-disable comment.

The return type was the main focus. Few more details got tweaked own the way.

Test plan

TS build and type tests should pass.

@@ -1089,12 +1089,11 @@ export class ModuleMocker {
methodKey: K,
): V extends ClassLike | FunctionLike ? Spied<V> : never;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
spyOn<T extends object, K extends PropertyLikeKeys<T>>(
spyOn<T extends object>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overloads are now way more readable. Nice to look at them.

One more detail I am leaving for the future iterations. The return type of spyOn and _spyOnProperty methods is MockInstance, but the value wich is return has to be cast using as Mock. This is because of the return type of _makeComponent method. It comes from overloads which are causing some type issues. That needs more thinking. So I am leaving this for the future.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! 👍

@SimenB SimenB merged commit ba20c15 into jestjs:main Nov 8, 2022
@mrazauskas mrazauskas deleted the refactor-mock-clean-up-types-more branch November 8, 2022 13:21
@github-actions
Copy link

github-actions bot commented Dec 9, 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 Dec 9, 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