简体   繁体   English

使用create-react-app --typescript创建的应用中的错误

[英]errors in app created with create-react-app --typescript

I created a new app using create-react-app with the --typescript flag. 我使用带有--typescript标志的create-react-app创建了一个新应用。 This generates the file App.tsx. 这将生成文件App.tsx。 When I open this file in VS Code I get lots of "problems" identified before I even change any of the generated code. 当我在VS Code中打开此文件时,我什至在更改任何生成的代码之前都会发现很多“问题”。 The first error is on the "div" tag returned by the render method. 第一个错误是在render方法返回的“ div”标签上。 It says "Cannot find name 'div'". 它说“找不到名称'div'”。 Running tslint doesn't output any errors. 运行tslint不会输出任何错误。 Is there some configuration I need to do in VS Code to remove these problems? 我需要在VS Code中进行一些配置以消除这些问题吗?

You can try with this command with npm: 您可以在npm中尝试使用此命令:

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

npx comes with npm 5.2+ and higher, so if your npm version is below 5.2 you should update it npx随附npm 5.2及更高版本,因此,如果您的npm版本低于5.2,则应对其进行更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM