【问题标题】:errors in app created with create-react-app --typescript使用 create-react-app --typescript 创建的应用程序中的错误
【发布时间】:2019-05-10 04:52:42
【问题描述】:

我使用带有 --typescript 标志的 create-react-app 创建了一个新应用。这将生成文件 App.tsx。当我在 VS Code 中打开这个文件时,我什至在更改任何生成的代码之前就发现了很多“问题”。第一个错误出现在 render 方法返回的“div”标签上。它说“找不到名称'div'”。运行 tslint 不会输出任何错误。我需要在 VS Code 中进行一些配置来消除这些问题吗?

【问题讨论】:

    标签: reactjs typescript visual-studio-code create-react-app


    【解决方案1】:

    你可以用 npm 试试这个命令:

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

    npx 自带 npm 5.2+ 及更高版本,所以如果你的 npm 版本低于 5.2,你应该更新它

    【讨论】:

      猜你喜欢
      • 2021-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 2019-11-29
      • 2022-10-20
      • 1970-01-01
      • 2018-07-14
      相关资源
      最近更新 更多