Dav*_*ord 44 reactjs create-react-app
是否可以将TypeScript与create-react-app一起使用?如果是这样,你会怎么做?
小智 49
你可以这样做:
create-react-app my-app --scripts-version=react-scripts-ts
Run Code Online (Sandbox Code Playgroud)
请参阅https://github.com/wmonk/create-react-app-typescript
不需要弹出.
Tan*_*ong 19
Create React App v2.1.0现在支持TypeScript,因此您不再需要弹出或使用react-scripts-tsfork;
# update create-react-app first
npm update -g create-react-app
create-react-app my-app --typescript
Run Code Online (Sandbox Code Playgroud)
然后将.js文件重命名为.tsx文件以开始使用TypeScript.
或者使用TypeScript启动一个新项目:
yarn add typescript @types/node @types/react @types/react-dom @types/jest
# or
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
Run Code Online (Sandbox Code Playgroud)
请注意,运行应用程序时将为您创建tsconfig.json.除了一些选项,您将能够编辑tsconfig.json .
积分:
[1] 文森特回答
[2] 迁移创建反应应用程序打字稿帖子
| 归档时间: |
|
| 查看次数: |
17820 次 |
| 最近记录: |