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

asymmetric matcher type definitions are not good (yet again) #550

Closed
hugebdu opened this issue Jan 8, 2023 · 18 comments · Fixed by #551
Closed

asymmetric matcher type definitions are not good (yet again) #550

hugebdu opened this issue Jan 8, 2023 · 18 comments · Fixed by #551

Comments

@hugebdu
Copy link

hugebdu commented Jan 8, 2023

After the recent change, cannot be used as nested in jest.
See this comment.

@SimenB
Copy link
Member

SimenB commented Jan 8, 2023

PR welcome to fix it 👍

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

@SimenB I'm not familiar with vitest and it's typings.
however this PR broke jest typings.

I could PR with a revert :)

@SimenB
Copy link
Member

SimenB commented Jan 9, 2023

/cc @rluvaton

@rluvaton
Copy link
Contributor

rluvaton commented Jan 9, 2023

Sorry 😬

Could you create a repro repo so I could take a look at it later today and fix it

@rluvaton
Copy link
Contributor

rluvaton commented Jan 9, 2023

I don't know how the current AsymmetricMatchers types works

As you can see in:

https://github.com/facebook/jest/blob/9af2540f87e8e0d4f1e0528981529ad1bc30a28a/packages/expect/src/types.ts#L114

The return type is AsymmetricMatcher and we return void (even before my change)

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

Could you create a repro repo so I could take a look at it later today and fix it

wil do
10x

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

@rluvaton
Copy link
Contributor

rluvaton commented Jan 9, 2023

@hugebdu could you please check if #551 working for you? it fixed it for me...

@SimenB Could you please review the PR 😄

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

@rluvaton negative. now I have

  ● Test suite failed to run

    test.spec.ts:17:7 - error TS2322: Type 'AsymmetricMatcher' is not assignable to type 'number'.

    17       baz: expect.toBeNumber()
             ~~~

      test.spec.ts:5:3
        5   baz?: number;
            ~~~
        The expected type comes from property 'baz' which is declared here on type 'Foo'

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

@rluvaton built-in asymmetric matchers (like expect.stringContaining) have any as return type

@rluvaton
Copy link
Contributor

rluvaton commented Jan 9, 2023

@rluvaton built-in asymmetric matchers (like expect.stringContaining) have any as return type

Where do you see that?

https://github.com/facebook/jest/blob/9af2540f87e8e0d4f1e0528981529ad1bc30a28a/packages/expect/src/types.ts#L119

@rluvaton
Copy link
Contributor

rluvaton commented Jan 9, 2023

change to any, could you please retry?

@SimenB
Copy link
Member

SimenB commented Jan 9, 2023

My guess is that they're any in @types/jest

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

@SimenB indeed

@hugebdu
Copy link
Author

hugebdu commented Jan 9, 2023

@rluvaton

change to any, could you please retry?

perfection 👍

@rluvaton
Copy link
Contributor

rluvaton commented Jan 9, 2023

thanks, so it's ready for review 😄

@SimenB
Copy link
Member

SimenB commented Jan 10, 2023

https://github.com/jest-community/jest-extended/releases/tag/v3.2.3

@hugebdu
Copy link
Author

hugebdu commented Jan 10, 2023

@SimenB @rluvaton
Thank you guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants