testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.
https://testing-library.com/react
MIT License
19.04k stars 1.11k forks source link

Fix type import from react-dom #1337

Closed grncdr closed 5 months ago

grncdr commented 5 months ago

What:

Fix the imported Container type from react-dom

Why:

The react-dom/client module does not export the Container type, only react-dom does.

How:

Updating types/index.d.ts

Checklist:

Thanks for the great library! 👍

codesandbox-ci[bot] commented 5 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 470215124084c5c61c7911543fd6ebb81d720639:

Sandbox Source
react-testing-library-examples Configuration
MatanBobi commented 5 months ago

Hi @grncdr, thanks for taking the time to open this.

Container does exist in react-dom/client as can be seen here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b0ea84700707b027d6eb37328b16b294dcc9d31a/types/react-dom/client.d.ts#L41

But it really depends on the type of ReactDOM you're using. The separation didn't exist in React 17 AFAIR.

grncdr commented 5 months ago

Hi @MatanBobi, first sorry for opening a spurious issue, and thanks for the pointer to the actual problem.

I'm using React 18 but didn't notice @types/react-dom had been pinned to 18.0.1 via a yarn resolution. Updating to 18.3.0 resolved it for me. 👍