Skip to content

Commit 3496287

Browse files
committed
Simplify TypeScript setup instructions
1 parent 6182253 commit 3496287

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

docusaurus/docs/adding-typescript.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ id: adding-typescript
33
title: Adding TypeScript
44
---
55

6-
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
6+
[TypeScript](https://www.typescriptlang.org/) is a typed superset of JavaScript that compiles to plain JavaScript.
77

8-
Recent versions of [TypeScript](https://www.typescriptlang.org/) work with Create React App projects out of the box thanks to Babel 7. Note that Babel 7 TypeScript does not allow some features of TypeScript such as constant enum and namespaces.
8+
To add [TypeScript](https://www.typescriptlang.org/) to a Create React App project, first install it:
99

10-
To add TypeScript to a Create React App project, follow these steps:
10+
```bash
11+
$ npm install --save typescript @types/react @types/react-dom @types/jest
12+
$ # or
13+
$ yarn add typescript @types/react @types/react-dom @types/jest
14+
```
1115

12-
1. Run `npm install --save typescript @types/react @types/react-dom @types/jest` (or `yarn add typescript @types/react @types/react-dom @types/jest`).
13-
2. Rename `src/index.js` to `src/index.tsx` or create an empty [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) at the root project directory.
14-
3. Restart your development server (if applicable). This will set sensible defaults and the required values in your [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
16+
Next, rename any file to be a TypeScript file (e.g. `src/index.js` to `src/index.tsx`) and **restart your development server**!
1517

1618
Type errors will show up in the same console as the build one.
1719

18-
We recommend using [VSCode](https://code.visualstudio.com/) for a better integrated experience.
19-
2020
To learn more about TypeScript, check out [its documentation](https://www.typescriptlang.org/).
21+
22+
> Note: We recommend using [VSCode](https://code.visualstudio.com/) for a better integrated experience.
23+
24+
> Note: Constant enum and namespaces are not supported.

0 commit comments

Comments
 (0)