reactjs - 无法创建 React Typescript 应用程序

标签 reactjs typescript create-react-app

当我在cmd中执行命令时:

npx create-react-app my-app --typescript

应用程序似乎是 typescript ,但是当我在 VS 代码中打开文件夹时,我发布了 src 文件夹中的所有文件都带有 .js 扩展名而不是 .ts(.tsx) 扩展.. 我尝试通过 cmd(管理员模式)创建应用程序但没用,没有改变。我也尝试使用命令:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

仍然没有。

没有错误。应用程序像标准的 react+js 应用程序一样工作。

最佳答案

尝试:

npx create-react-app my-app --scripts-version=react-scripts-ts

或:

yarn create react-app my-app --scripts-version=react-scripts-ts

关于reactjs - 无法创建 React Typescript 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56169283/

相关文章:

reactjs - 我该如何做类似 redux `connect()` - 在声明时将 props 放入组件中的事情?

javascript - 我在 Vite 3.2.4 版本中不断收到错误,显示 `[vite:esbuild] The service is no longer running: write EPIPE`

javascript - Github - 读取边带数据包时意外断开连接

javascript - React Router - OnClick 未在 Navlink 中处理

Angular "APP_INITIALIZER"在 Angular 4 中有没有 promise 的服务?

reactjs - asp.net core 2.1 Webpack 4 React 无法正常启动

javascript - Gulp:为缩小和非缩小脚本生成源映射

reactjs - 为什么 create-react-app 同时创建 App.js 和 index.js?

reactjs - create-react-app 自 4.0.1 版起不起作用

reactjs - npx create-react-app 每次都花费太长时间