Skip to content

@types/react-dom incorrectly declared as a devDependency #1000

@fmeum

Description

@fmeum
  • @testing-library/react version: v12.1.2
  • Testing Framework and version: N/A
  • DOM Environment: N/A

What you did:

Tried to use @testing-library/react in a TS web app built with Bazel's rules_nodejs, which enforce strict visibility between NPM packages as determined by their declared dependencies.

What happened:

Got the following tsc error when compiling a test that uses @testing-library/react with rules_nodejs:

node_modules/@testing-library/react/types/index.d.ts(9,24): error
TS2307: Cannot find module 'react-dom' or its corresponding type
declarations.
node_modules/@testing-library/react/types/index.d.ts(10,31): error
TS2307: Cannot find module 'react-dom/test-utils' or its corresponding
type declarations.

Problem description:

@testing-library/react declares @types/react-dom as a devDependency, but uses it in its external interface when used from TypeScript.

Suggested solution:

Mark @types/react-dom as a regular dependency of @testing-library/react so that packages depending on @testing-library/react also pick up this dependency.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions