【问题标题】:Visual Studio Code - TypeScript - not showing errors inline when tsconfig.json contains dataVisual Studio Code - TypeScript - 当 tsconfig.json 包含数据时不显示内联错误
【发布时间】:2018-09-21 11:41:20
【问题描述】:

当我添加一个空的 .tsconfig 文件(空我的意思是“{ }”)时,Visual Studio 代码在“问题”部分显示内联错误。一旦我将数据添加到 tsconfig.json 文件,那里就不再显示错误。 我是否需要设置一些默认设置但在编辑 tsconfig.json 时不需要的特定设置?

这是我的 tsconfig.json:

{ 
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "outDir": "dist",
        "sourceMap": true,
        "checkJs": true,
    },
    "files": [
        "./node_modules/@types/mocha/index.d.ts",
        "./node_modules/@types/node/index.d.ts",
    ],
    "include": [
        "src/**/*.ts"
    ],
    "exclude": [
        "node_modules"
    ],
    "compileOnSave": true
}

我已经尝试按照here 的建议从文件中删除 "module": "commonjs" 但这对我不起作用。

【问题讨论】:

  • 删除files,错误的用法和打字自动检查@types
  • @Marv 我删除了files,但错误仍未突出显示。
  • 尝试重命名为 tsconfig.json,这可能是 vscode 寻找的默认名称。并且每当进行更改时,重新加载 vscode 窗口
  • 文件已经命名为tsconfig.json。更改后重新加载似乎也对我没有帮助。

标签: typescript visual-studio-code


【解决方案1】:

我玩弄了 tsconfig.json 并想出了以下内容:

{ 
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "sourceMap": true
    },
    "exclude": [
        "node_modules"
    ],
    "compileOnSave": true
}

我不知道为什么,但这解决了我的问题。

【讨论】:

  • 在类似情况下,将 "target":"es5" 更改为 "es6" 会有所帮助。当然这里不是这样,你原来的配置已经有了"target": "es6"
猜你喜欢
  • 2017-05-25
  • 2020-10-20
  • 2017-04-18
  • 1970-01-01
  • 2018-10-27
  • 2015-12-04
  • 1970-01-01
  • 1970-01-01
  • 2019-08-02
相关资源
最近更新 更多