How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found" How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found" reactjs reactjs

How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found"


Just update react-scripts. I solved it by uninstall and install again.In command line:

uninstall:

npm uninstall react-scripts --save

and install again:

npm i react-scripts


When I ran into this, I had created a brand new app using create-react-app my-app --typescript then copied the dependencies from another project that I had just finished. After messing around with things I noticed that the react-scripts was at version 3.1.1, when I finally got this running again the working package.json had it at 3.1.2 looks like this is the culprit. A working package.json would look like:

{  "name": "my-app",  "version": "0.1.0",  "private": true,  "dependencies": {    "@types/jest": "24.0.18",    "@types/node": "12.7.5",    "@types/react": "16.9.2",    "@types/react-dom": "16.9.0",    "node-sass": "^4.12.0",    "react": "^16.9.0",    "react-dom": "^16.9.0",    "react-scripts": "3.1.2",    "typescript": "3.6.3"  },  "scripts": {    "start": "react-scripts start",    "build": "react-scripts build",    "test": "react-scripts test",    "eject": "react-scripts eject"  },  "eslintConfig": {    "extends": "react-app"  },  "browserslist": {    "production": [      ">0.2%",      "not dead",      "not op_mini all"    ],    "development": [      "last 1 chrome version",      "last 1 firefox version",      "last 1 safari version"    ]  }}

Trying to get the error to disappear was a challenge, there is an evil bug in Visual Studio that will leave your VSCompiler.exe and other services hung up only using the version of the file that it had when the services hung up. No matter what you do nothing will work until you get these restarted, see this answer on some tips how to resolve it, I realize it is for Angular but the same principles apply.


I found a solution.1) Delete the node_modules2) update the Package.Json line of React-scripts to this: ""react-scripts": "3.1.2""3) run npm i

This should work