1

I am trying to use React 17 in a codebase that previously used version 18 (because Mobx currently has partial support for 18 and I need to debug a CPU load issue), but this seems to result in a TS types version conflict.

The TS compiler tells me that the ReactNode type from my component is not compatible with the same type that is imported from my styled-components package, and if I run yarn why @types/react I get:

yarn why @types/react
├─ @gemini/review-app@workspace:packages/review-app
│  └─ @types/react@npm:17.0.47 (via npm:^17)
│
...
│
└─ @types/styled-components@npm:5.1.25
   └─ @types/react@npm:18.0.9 (via npm:*)

My repository is using Yarn 3 with workspaces. How can I tell yarn to resolve to React 17 types for styled-components?

I have already tried things like:

yarn set resolution @types/react@npm:18.0.9 17.0.47 --save
yarn set resolution @types/react@npm:^18 17.0.47 --save
yarn set resolution @types/react@npm:* 17.0.47 --save

...but it doesn't seem to do anything (no changes in the lock file either)

Thijs Koerselman
  • 21,680
  • 22
  • 74
  • 108

1 Answers1

0

I got something to work using a ~ (tilde) resolution, so this command, in my case:

yarn set resolution --save underscore@npm:~1.4.4 1.12.1

Don't know if that will help you, but it at least edited my yarn.lock. Didn't seem to change anything else, unfortunately, still trying to figure that out.

Gert Sønderby
  • 713
  • 7
  • 16