reactjs - Typescript-problem efter uppdatering till create-react-app 4.0.0


Jag har precis uppdaterat create-react-app till 4.0.0 och jag har stött på många problem. Det första var

TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible

Jag löste det genom att lägga till "noFallthroughCasesInSwitch": true, i min tsconfig.json

Nu kan jag starta appen, men allt gick bara fel. Jag har miljontals uppenbarligen oanvända variabler, även om de inte är det.

Jag har uppdaterat typescript till 4.0.5 men problemet kvarstår.

Dessutom blir min maskin mycket högljudd när jag kör yarn start

Svar #1

du kan tillfälligt stänga av eslint-fel no-unused-vars och @typescript-eslint/no-unused-vars i filen .eslintrc. Till exempel

{
  "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"
  }
}

Relaterade artiklar