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

TypeScript error with skipLibCheck false #1311

Closed eps1lon closed 7 months ago

eps1lon commented 7 months ago
          @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

Originally posted by @AviVahl in https://github.com/testing-library/react-testing-library/issues/1304#issuecomment-2074958252

AviVahl commented 7 months ago

Ah, I should have probably opened the issue. Thanks for that. Much appreciated.

AviVahl commented 7 months ago

thanks for the fix. any chance for a patch release?

MatanBobi commented 7 months ago

thanks for the fix. any chance for a patch release?

This should be automatic but looks like our CI failed, I'll have a look.

MatanBobi commented 7 months ago

@AviVahl Re-running did the trick, version 15.0.5 is released with that fix :) Sorry about that and thanks for the ping.