Skip to content

TypeScript Error with latest dom-testing-library #330

Closed
@pschyma

Description

@pschyma

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions