ionic-team / stencil-ds-output-targets

These are output targets that can be added to Stencil for React and Angular.
https://stenciljs.com
MIT License
251 stars 116 forks source link

bug: Error running Jest: Interface 'Matchers<R, T>' incorrectly extends interface 'TestingLibraryMatchers<(str: string) => any, R>' #261

Open nareshbhatia opened 2 years ago

nareshbhatia commented 2 years ago

Prerequisites

Stencil Version

2.16.1

Stencil Framework Output Target

React

Stencil Framework Output Target Version

0.3.1

Current Behavior

Jest errors out if I try to use the latest version of react-testing-libray@13.3.0:

stencil-library:dev: > stencil build --dev --watch --serve
stencil-library:dev:
stencil-library:dev: [09:03.6]  @stencil/core
stencil-library:dev: [09:03.8]  v2.16.1 🎻
stencil-library:dev: [09:06.4]  build, stencil-demo, dev mode, started ...
stencil-library:dev: [09:06.4]  transpile started ...
stencil-library:dev: [09:09.8]  transpile finished in 3.37 s
stencil-library:dev: [09:10.1]  build, stencil-demo, dev mode, started ...
stencil-library:dev: [09:10.1]  transpile started ...
stencil-library:dev: [09:13.4]  transpile finished in 3.23 s
stencil-library:dev:
stencil-library:dev: [ ERROR ]  TypeScript: ../../node_modules/@types/jest/index.d.ts:691:15
stencil-library:dev:            Interface 'Matchers<R, T>' incorrectly extends interface
stencil-library:dev:            'TestingLibraryMatchers<(str: string) => any, R>'.The types returned
stencil-library:dev:            by 'toHaveAttribute(...)' are incompatible between these types.Type
stencil-library:dev:            'void' is not assignable to type 'R'.'R' could be instantiated with
stencil-library:dev:            an arbitrary type which could be unrelated to 'void'.
stencil-library:dev:
stencil-library:dev:     L690:  // should be R extends void|Promise<void> but getting dtslint error
stencil-library:dev:     L691:  interface Matchers<R, T = {}> {
stencil-library:dev:     L692:      /**
stencil-library:dev:
stencil-library:dev: [09:13.4]  build failed, watching for changes... in 3.25

Expected Behavior

We should be able to use stencil with latest version of react-testing library (v13; or at least v12 if not supporting React 18 yet).

Steps to Reproduce

Please see my monorepo here. The last commit fixes the issue by removing react-testing-library completely. (It also downgrades from React v18 to React v17, but that's just because I understand that Stencil does not support React v18 yet.)

For the commit before that you just need to run npm run dev to see the errors mentioned above.

Code Reproduction URL

https://github.com/nareshbhatia/stencil-demo

Additional Information

I notice that react-output-target is using a very old version of react-testing-library (v7):

https://github.com/ionic-team/stencil-ds-output-targets/blob/main/packages/react-output-target/package.json#L43

willholmeswastaken commented 1 year ago

Add the following line to your tsconfig.json

"skipLibCheck": true,

Works for me.

lodybo commented 1 year ago

We're also running into this and prevents us from using the Storybook interaction tests, since they're depending on React Testing Library (and React).

Using skipLibCheck could work but we'd rather not turn it on because we like to have our Node modules checked.

marksyzm commented 7 months ago

Still an issue :)

ionitron-bot[bot] commented 4 weeks ago

This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort. Thank you!