How to setup VSCode to show typescript error inline

后端 未结 4 1397

I\'m trying to migrate an ES6 project to typescript. This is my first attempt at writing a typescript module in NodeJS.

It seems to work better in Angular-CLI so far.

相关标签:
4条回答
  • 2021-02-18 15:54

    Even without having installed TypeScript locally or globally, the following setup provides inline errors.

    C:/temp
      index.ts
      tsconfig.json
    

    index.ts

    let x: number;
    x = "foo";
    

    tsconfig.json

    { }
    

    Here is a screenshot that shows the inline error in x.

    Please try that setup and report back on what happens.

    0 讨论(0)
  • 2021-02-18 16:10

    I just closed & restarted my VS Code and it started showing typescript errors like before.

    If this doesn't work, I'd suggest restarting your computer system.

    0 讨论(0)
  • 2021-02-18 16:13

    I ran aground with this issue, managed to solve it by adding "typescript.validate.enable": true to my local settings.json file in the .vscode directory. My settings tell me that the typescript validator is enabled for VS code globally, but I wasn't able to see inline TS errors until I added the local settings file.

    0 讨论(0)
  • 2021-02-18 16:17

    For me the problem was resolved by setting Typescript validation to true in VSCode settings:

    "typescript.validate.enable": true,
    

    I had turned this off in my workspace settings in the past and forgot!

    So make sure to double check that this setting is not set to false in your user settings, workspace settings or folder settings.

    For instance the rule I was trying to get work was checking for undefined variables which was immediately fixed when I set validate to true.

    0 讨论(0)
提交回复
热议问题