Adding TypeScript to existing create-react-app app

As of react-scripts 2.10 you can add TypeScript to an existing project or when creating a new project.

existing project

yarn add typescript @types/node @types/react @types/react-dom @types/jest --dev

…then rename your .js files to .tsx

new project

yarn create react-app my-app --template typescript

You can read more in the docs.

If you are having trouble, the following from the troubleshooting section of the docs might help:

Troubleshooting

If your project is not created with TypeScript enabled, npx may be
using a cached version of create-react-app. Remove previously
installed versions with npm uninstall -g create-react-app or yarn
global remove create-react-app (see #6119).

Leave a Comment