Skip to content

TypeScript Error with latest dom-testing-library #330

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

Closed
pschyma opened this issue Mar 21, 2019 · 3 comments · Fixed by #331
Closed

TypeScript Error with latest dom-testing-library #330

pschyma opened this issue Mar 21, 2019 · 3 comments · Fixed by #331
Labels

Comments

@pschyma
Copy link
Contributor

pschyma commented Mar 21, 2019

I'm not sure whether this rather belongs into dom-testing-library...

  • react-testing-library version: 6.0.1
  • react version: 16.8.4
  • node version: 10.15.3
  • npm (or yarn) version: 1.15.2

Relevant code or config:

We are using a default CRA2 setup. There is no dependency on dom-testing-library defined on the project; only react-testing-library.

What you did:

yarn update

What happened:

yarn start now yields:

node_modules/react-testing-library/typings/index.d.ts
TypeScript error: Type 'typeof import("./node_modules/dom-testing-library/typings/queries")' does not satisfy the constraint 'Queries'.
  Property 'findByLabelText' is incompatible with index signature.
    Type 'FindByText' is not assignable to type 'Query'.
      Type 'Error | Promise<HTMLElement>' is not assignable to type 'HTMLElement | HTMLElement[] | null'.
        Type 'Error' is not assignable to type 'HTMLElement | HTMLElement[] | null'.
          Type 'Error' is missing the following properties from type 'HTMLElement[]': length, pop, push, concat, and 26 more.  TS2344

    11 | }
    12 | 
  > 13 | export type RenderResult<Q extends Queries = typeof queries> = {
       |                                              ^
    14 |   container: HTMLElement
    15 |   baseElement: HTMLElement
    16 |   debug: (baseElement?: HTMLElement | DocumentFragment) => void

After pinning dom-testing-library to version 3.18.1 via resolutions everything compiles again.

Reproduction:

Problem description:

Suggested solution:

@kentcdodds
Copy link
Member

I don't maintain the typescript typings. If anyone would like to open a pull request to fix this I will merge it.

@pschyma pschyma mentioned this issue Mar 21, 2019
5 tasks
@pschyma
Copy link
Contributor Author

pschyma commented Mar 21, 2019

I prepared a quick fix for this.

@kentcdodds
Copy link
Member

🎉 This issue has been resolved in version 6.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

lucbpz pushed a commit to lucbpz/react-testing-library that referenced this issue Jul 26, 2020
…ab-respect-radio-groups

fix(tab): make tab respect radio groups (fix testing-library#207)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants