react-test-rendererをnpm でinstallしようとしてエラー


$ npm i --save-dev react-test-renderer@18
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: expo3@1.0.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR!   react@"18.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.2.0" from react-test-renderer@18.2.0
npm ERR! node_modules/react-test-renderer
npm ERR!   dev react-test-renderer@"18" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/xxxx/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxx/.npm/_logs/2022-08-26T06_58_11_882Z-debug.log


React (version 18)
React native
Typescript ← ここ重要。


npm でインストールする際に、typescriptとしてインストールすれば解決しました。つまり以下のコマンドを打てば良いです。

npm i –save-dev @types/react-test-renderer@18

$ npm i --save-dev @types/react-test-renderer@18

up to date, audited 1671 packages in 2s

117 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities