Skip to content
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

fix: Don't raise TypeScript errors when hydating document #1304

Merged
merged 1 commit into from Apr 23, 2024

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Apr 22, 2024

Closes #1250

As a follow-up, we need to make @types/react-dom a peer dependency. Since react-dom is a peer, the types also need to be peer. Otherwise you would get the wrong version of @types/react-dom if you'd install React 19.

Copy link

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 6c1fdf7:

Sandbox Source
react-testing-library-examples Configuration

@eps1lon eps1lon changed the title Don't raise TypeScript errors when hydating document fix:Don't raise TypeScript errors when hydating document Apr 22, 2024
@eps1lon eps1lon changed the title fix:Don't raise TypeScript errors when hydating document fix: Don't raise TypeScript errors when hydating document Apr 22, 2024
@eps1lon eps1lon requested a review from MatanBobi April 22, 2024 12:43
Copy link
Member

@MatanBobi MatanBobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to merge this as a fix before merging the peer deps change?

@eps1lon
Copy link
Member Author

eps1lon commented Apr 23, 2024

Do we want to merge this as a fix before merging the peer deps change?

Yeah, I also want to wait a week (or until React 19 alpha comes out) before merging #1305

@eps1lon eps1lon merged commit 067d0c6 into testing-library:main Apr 23, 2024
10 checks passed
@eps1lon eps1lon deleted the hydrate-document branch April 23, 2024 10:21
@AviVahl
Copy link

AviVahl commented Apr 24, 2024

@eps1lon we see type errors since this change:

node_modules/@testing-library/react/types/index.d.ts:129:52 - error TS2344: Type 'Container' does not satisfy the constraint 'Element | DocumentFragment'.
  Type 'Document | Container' is not assignable to type 'Element | DocumentFragment'.
    Type 'Document' is not assignable to type 'Element | DocumentFragment'.
      Type 'Document' is missing the following properties from type 'Element': attributes, classList, className, clientHeight, and 100 more.
        Type 'Container' is not assignable to type 'DocumentFragment'.
          Type 'Document | Container' is not assignable to type 'DocumentFragment'.
            Type 'Document' is not assignable to type 'DocumentFragment'.
              Types of property 'ownerDocument' are incompatible.
                Type 'null' is not assignable to type 'Document'.

can be reproduced with:

mkdir check-testinglib
cd check-testinglib
npm init -y
npm i react react-dom @types/react @types/react-dom typescript @testing-library/react
npx tsc --init --outDir dist --skipLibCheck false
echo "export * from '@testing-library/react';" > test.ts
npx tsc --noEmit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test layout.tsx file without having validateDOMNesting warning
3 participants