【问题标题】:VS Code not showing Typescript errors inlineVS Code 未内联显示 Typescript 错误
【发布时间】:2020-10-20 11:37:46
【问题描述】:

我很困惑为什么我的 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

【问题讨论】:

  • 您是否禁用了内置的 JS/TS 扩展?在扩展视图中,搜索@builtin typescript 进行检查。另外,您的设置无效。属性应该在顶层,而不是在 settings 对象内
  • 下面是我的答案,当我添加那个打字稿神扩展时,这一切都开始了。不管怎样,我明天会试试你说的。感谢您的评论
  • 你不应该需要任何扩展来工作。
  • 我知道,这很奇怪 - 我尝试将它们移到顶层,但它们仍然是灰色的

标签: typescript visual-studio-code


【解决方案1】:

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

我添加了 VSCode 扩展 TypeScript God,然后它就全部启动了。

【讨论】:

  • 此扩展不再列在 VS Code 市场中
猜你喜欢
  • 1970-01-01
  • 2019-01-15
  • 1970-01-01
  • 2021-11-06
  • 1970-01-01
  • 2023-01-20
  • 1970-01-01
  • 2017-05-25
  • 2019-01-31
相关资源
最近更新 更多