mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 17:12:59 +08:00
Update adding-typescript.md
This commit is contained in:
@@ -10,17 +10,21 @@ title: Adding TypeScript
|
||||
To start a new Create React App project with [TypeScript](https://www.typescriptlang.org/), you can run:
|
||||
|
||||
```bash
|
||||
$ npx create-react-app my-app --typescript
|
||||
$ # or
|
||||
$ yarn create react-app my-app --typescript
|
||||
npx create-react-app my-app --typescript
|
||||
|
||||
# or
|
||||
|
||||
yarn create react-app my-app --typescript
|
||||
```
|
||||
|
||||
To add [TypeScript](https://www.typescriptlang.org/) to a Create React App project, first install it:
|
||||
|
||||
```bash
|
||||
$ 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
|
||||
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**!
|
||||
|
||||
Reference in New Issue
Block a user