jest-community/jest-extended

asymmetric matcher type definitions are not good (yet again)

hugebdu opened this issue ยท 18 comments

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

PR welcome to fix it ๐Ÿ‘

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

I could PR with a revert :)

Sorry ๐Ÿ˜ฌ

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

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)

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

wil do
10x

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

@SimenB Could you please review the PR ๐Ÿ˜„

@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'

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

@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

change to any, could you please retry?

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

@rluvaton

change to any, could you please retry?

perfection ๐Ÿ‘

thanks, so it's ready for review ๐Ÿ˜„

@SimenB @rluvaton
Thank you guys