skip to Main Content

i get errors in vscode but every thing works correctly .
some errors :

Type expected.

[{
    "resource": "/C:/Users/Dell/Desktop/vite-project/src/App.tsx",
    "owner": "typescript",
    "code": "1110",
    "severity": 8,
    "message": "Type expected.",
    "source": "ts",
    "startLineNumber": 10,
    "startColumn": 6,
    "endLineNumber": 10,
    "endColumn": 7
}]

Cannot find name 'div'.
'>' expected.

somthing wrong in vscode settings

everything works

2

Answers


  1. Chosen as BEST ANSWER

    I was able to resolve the issue by updating the "jsx" setting in my tsconfig.json file. Initially, it was set to "jsx": "react", but changing it to "jsx": "preserve" solved the problem for me. Here's the updated snippet from my tsconfig.json:

    {
      "compilerOptions": {
        // ...
        "jsx": "preserve"
      }
    }
    

    Additionally, I updated the TypeScript version to use the workspace version.


  2. To hone in on the issue open an empty folder with vsc and in terminal try:

    npx create-react-app example-name --template typescript
    
    • If npm start works then we know there is not an issue with ts.
    • slowly add contents of the original application (maybe save vlite or whatever lib broke it for last)
    • If something you add breaks it, at least we can hone in on what caused it.
    • If nothing broke it then there must have been an issue on set up or possibly accidentally deleted files etc.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search