Note: this feature is available with
To start a new Create React App project with TypeScript, you can run:
npx create-react-app my-app --typescript # or yarn create react-app my-app --typescript
To add TypeScript to a Create React App project, first install it:
npm install --save typescript @types/node @types/react @types/react-dom @types/jest # or yarn add typescript @types/node @types/react @types/react-dom @types/jest
Next, rename any file to be a TypeScript file (e.g.
src/index.tsx) and restart your development server!
Type errors will show up in the same console as the build one.
To learn more about TypeScript, check out its documentation.
Note: You are not required to make a
tsconfig.jsonfile, one will be made for you. You are allowed to edit the generated TypeScript configuration.
Note: We recommend using VSCode for a better integrated experience.
Note: Constant enums and namespaces are not supported.