Now that TypeScript 5 was released (specifically, typescript@5.0.2
), it would be great to get the restriction on the version of TypeScript removed.
Otherwise npm will throw errors like this, when resolving peer dependencies:
CodeSandbox demo (run npm i
in a terminal to get the error below): https://codesandbox.io/p/sandbox/react-scripts-5-0-1-typescript-5-0-2-t48wwi
$ npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@5.0.1
npm ERR! Found: typescript@5.0.2
npm ERR! node_modules/typescript
npm ERR! dev typescript@"5.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"5.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"5.0.1" 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 /project/home/karlhorky/.cache/npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /project/home/karlhorky/.cache/npm/_logs/2023-03-17T11_12_53_021Z-debug-0.log
Alternatives considered
I could instead do this if desired, which would then need to be updated again each time TypeScript 6, 7, etc are released:
- "typescript": "^3.2.1 || ^4"
+ "typescript": "^3.2.1 || ^4 || ^5"