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

@types/react@17 installed #610

Closed
thoughtspile opened this issue Apr 27, 2021 · 3 comments
Closed

@types/react@17 installed #610

thoughtspile opened this issue Apr 27, 2021 · 3 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@thoughtspile
Copy link

thoughtspile commented Apr 27, 2021

I'm not quite sure what happens, but despite @types/react: >=16.9.0 in RTL that should hoist to our @types/[email protected], version 17.0.4 is installed in node_modules/@testing-library/react-hooks/node_modules/@types/react and ambient types explode.

  • react-hooks-testing-library version: 5.1.2
  • react version: 16.9
  • yarn version: [email protected]

Yarn why output:

=> Found "@types/[email protected]"
info Has been hoisted to "@types/react"
info Reasons this module exists
   - Specified in "devDependencies"
   - Hoisted from "@types#react-dom#@types#react"
   - Hoisted from "@testing-library#react-hooks#@types#react-test-renderer#@types#react"
info Number of shared dependencies: 2
=> Found "@testing-library/react-hooks#@types/[email protected]"
info This module exists because "@testing-library#react-hooks" depends on it.
info Number of shared dependencies: 3
=> Found "@testing-library/react-hooks#@types/react-dom#@types/[email protected]"
info Reasons this module exists
   - "@testing-library#react-hooks#@types#react-dom" depends on it
   - Specified in "devDependencies"
info Number of shared dependencies: 2

Suggested solution:

I've seen things like "@types/react": "^16.9.34 || ^17.0.0", but I'm not sure what the effect is (or if it works at all).

As a workaround:

"resolutions": {
  "@testing-library/react-hooks/@types/react": "^16.9.0"
},
@thoughtspile thoughtspile added the bug Something isn't working label Apr 27, 2021
@mpeyper
Copy link
Member

mpeyper commented Apr 27, 2021

Hi @thoughtspile,

I'm not sure how much control we're going to have over this one, but there seems to be difference between how yarn and npm resolve the dependencies:

❯ yarn add react@^16.9 @types/react@^16.9 @types/react-dom@^16.9 @types/react-test-renderer@^16.9 @testing-library/react-hooks@^5.1
yarn add v1.22.10
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 11 new dependencies.
info Direct dependencies
├─ @testing-library/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
└─ [email protected]
info All dependencies
├─ @testing-library/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
✨  Done in 1.71s.

❯ yarn list --pattern "@types/react"                                                                                               
yarn list v1.22.10
├─ @testing-library/[email protected]
│  ├─ @types/[email protected]
│  ├─ @types/[email protected]
│  └─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
└─ @types/[email protected]
✨  Done in 0.06s.

vs.

❯ npm i react@^16.9 @types/react@^16.9 @types/react-dom@^16.9 @types/react-test-renderer@^16.9 @testing-library/react-hooks@^5.1
npm notice created a lockfile as package-lock.json. You should commit this file.

+ [email protected]
+ @types/[email protected]
+ @types/[email protected]
+ @testing-library/[email protected]
+ @types/[email protected]
added 17 packages from 41 contributors and audited 18 packages in 1.193s
found 0 vulnerabilities

❯ npm ls @types/react                                                                                                        
/Users/michaelpeyper/delete_me
└─┬ @testing-library/[email protected]
  ├── @types/[email protected] 
  ├─┬ @types/[email protected]
  │ └── @types/[email protected]  deduped
  └─┬ @types/[email protected]
    └── @types/[email protected]  deduped

It seems this is a known issue when resolving types with ranges but the yarn team have some strong feelings that they are being more correct about this.

@mpeyper
Copy link
Member

mpeyper commented Apr 29, 2021

I'll close this now, but please feel free to continue the discussion if you want.

@mpeyper mpeyper closed this as completed Apr 29, 2021
@mpeyper mpeyper added the wontfix This will not be worked on label Apr 29, 2021
@thoughtspile
Copy link
Author

Thanks @mpeyper :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants