将打字稿添加到 create-react-app 时出现 tslint 问题

tslint problem when adding typescript to create-react-app

我尝试将打字稿添加到现有项目中,以便我可以开始学习它。到目前为止,我对打字稿的了解为零,并且 运行 遇到了问题。

Cannot find "path_to_project\tslint.json" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. Possible errors: - wrong context directory in webpack configuration (if tslint is not set or is a relative path in fork plugin configuration)
- wrong tslint path in fork plugin configuration (should be a relative or absolute path) - tslint path is not set to false in fork plugin configuration (if you want to disable tslint support)

我按照 create-react-app 网站上的说明安装了所需的 npm 模块并将 index.js 重命名为 index.tsx,我还将 react-scripts 更新为 react-scripts-tx (这不在说明中,但它修复了另一个错误。

我已尝试在我的项目中搜索 "tslint"、"ForkTsCheckerWebpackPlugin" 和 "webpack",但找不到任何地方来修复此错误。

答案好像是我用的是react-scripts-ts

我没有意识到这是第 3 方包,如果您使用的是官方解决方案则不需要它。