4

I am confused why my VSCode isn't showing any Typescript errors.

When I run tsc in the terminal then I do see the errors showing, but these are not in my files inline.

My current setup

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "allowJs": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "lib": [
      "es2015",
      "dom"
    ],
    "skipLibCheck": false
  },
  "include": [
    "src"
  ]
}

index.ts - Expected error thrown but not

const a: number = 'test';

enter image description here

I have also updated the settings in VS to add the following as per the advice from this link, but still not showing any errors.

https://stackoverflow.com/a/53134524/3284707

enter image description here

4
  • 1
    Have you disabled the builtin JS/TS extension? In the extensions view, search @builtin typescript to check. Also, your settings are invalid. The properties should be at the top level, not inside a settings object Commented Jun 30, 2020 at 20:02
  • It’s my answer below where it all kicked into life when I added that typescript god extension. I will try what you said tomorrow though anyways. Thanks for your comment Commented Jun 30, 2020 at 20:12
  • You should not need any extension for this to work. Commented Jul 1, 2020 at 17:49
  • I know, it’s weird - I tried moving those to the top level but they were still greyed out Commented Jul 1, 2020 at 17:53

1 Answer 1

4

For me, this issue was caused by VS Code using a different TSC version for intellisense than was installed in my project. My project's package.json specified 4.7.3, while VS Code was using 4.9.4. There was a change in 4.8.x that meant some code that didn't compile before now did (believe this was the change: Announcing TypeScript 4.8). Of course, VS Code didn't show this error because it was using a later version. So, I had the issue described by the OP where running TSC in the terminal showed errors, but VS Code didn't give me any feedback.

I strongly recommend changing VS Code's setting so that it uses the same TSC version as specified in your package.json. You can read about how to do that here: Using the workspace version of TypeScript

Moreover, and I'm not certain how this relates to VS Code and my project using different TSC versions, but after making VS Code use the same version as my project, various performance problems I had been experiencing when navigating to definition, viewing hover tooltips, and more were completely resolved. So, if you're experiencing performance issues like those, give this fix a try.

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.