Files
create-react-app/docusaurus/docs/adding-typescript.md
Joe Haddad eca0ec0d52 Refine how TypeScript env types are handled (#5593)
* Specify types in package

* Do not remove types file on eject

* Stop copying types into generated project

* Reference react and react-dom

* Reference node types

* Install node types as well

* Restore copying

* Add Node to the list of installed types

* Reference Jest types

* Remove jest types from install

* Remove jest from CRA install

* Remove Jest reference and let user do this themselves

* Stop copying types file

* Add types key to package.json

* Add appTypeDeclarations and create when missing

* Rename declarations file

* Add Jest back to install instructions

* Minimize diff
2018-10-27 22:11:47 -07:00

1.1 KiB

id, title
id title
adding-typescript Adding TypeScript

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

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.js to 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.json file, 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.