更新到 create-react-app 4.0.0 后出现打字稿问题

Mir*_*run 5 typescript reactjs create-react-app

我刚刚更新create-react-app4.0.0遇到了很多问题。第一个是

TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible

我通过添加"noFallthroughCasesInSwitch": true,到我的tsconfig.json

现在我可以启动该应用程序,但一切都出了问题。我有数百万个显然未被起诉的变量,尽管它们并非如此。

在此输入图像描述

我已经更新typescript了,4.0.5但是问题依然存在。

另外,当我敲击时,我的机器变得非常响亮yarn start

小智 3

您可以暂时关闭文件.eslintrc中的 eslint 错误no-unused-vars@typescript-eslint/no-unused-vars。例如

{
  "extends": [
    "react-app",
    "./node_modules/react-redux-typescript-scripts/eslint.js"
  ],
  "rules": {
    "camelcase": "off",
    "import/no-anonymous-default-export": "off",
    "@typescript-eslint/camelcase": "off",
    "no-unused-vars": "warn",
    "@typescript-eslint/no-unused-vars": "off",
    "@typescript-eslint/ban-ts-ignore": "off",
    "@typescript-eslint/ban-ts-comment": "off",
    "@typescript-eslint/no-empty-function": "off",
    "@typescript-eslint/explicit-module-boundary-types": "off",
    "@typescript-eslint/no-empty-interface": "off",
    "@typescript-eslint/ban-types": "off"
  }
}
Run Code Online (Sandbox Code Playgroud)