I’m having difficulties adding TypeScript to an already existing create-react-app application. Previously I’ve always added it before starting the project, simply by
create-react-app my-app --scripts-version=react-scripts-ts, but that doesn’t work now.
The only “solution” I found here is:
- Create a temporary project with
tslint.jsonfrom the temporary project src folder to your project’s
package.json, change all the references to
react-scripts-tsin the scripts section.
This just seems like a weird workaround, and not very efficient. Does anyone know if it’s possible to add it in a better way than this?
As of react-scripts 2.10 you can add TypeScript to an existing project or when creating a new project.
yarn add typescript @types/node @types/react @types/react-dom @types/jest --dev
…then rename your
.js files to
yarn create react-app my-app --template typescript
You can read more here.
Answered By – user1843640
Answer Checked By – Robin (BugsFixing Admin)