首页 > 解决方案 > VS Code 未内联显示 Typescript 错误

问题描述

我很困惑为什么我的 VSCode 没有显示任何 Typescript 错误。

当我在终端中运行 tsc 时,我确实看到了显示的错误,但这些不在我的内联文件中。

我目前的设置

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 - 抛出预期错误但没有

const a: number = 'test';

在此处输入图像描述

我还根据此链接的建议更新了 VS 中的设置以添加以下内容,但仍未显示任何错误。

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

在此处输入图像描述

标签: typescriptvisual-studio-code

解决方案


不确定这是否真的是一个合适的解决方案,但对我有用。

我添加了 VSCode 扩展 TypeScript God,然后一切都开始了。

在此处输入图像描述


推荐阅读