【问题标题】:When I use tsconfig in Visual Studio I get compiler errors but when I removed it I dont当我在 Visual Studio 中使用 tsconfig 时,我得到编译器错误,但是当我删除它时,我没有
【发布时间】:2016-11-05 14:06:06
【问题描述】:

您好,当我使用自定义 tsconfig 而不是 Visual Studio 自动为我设置的那个时,这个项目没有拾取 typescript 定义文件。

https://github.com/jvelezc/GridStackDemo/tree/master/src/GridStackDemo

问题是 tsconfig 是如何改变类型定义的发现能力的?

我有一个非常简单的 tsconfig

{
  "compileOnSave":true,
  "compilerOptions": {
    "target": "es6",
    "module": "system",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "allowSyntheticDefaultImports": true
  },
  "files": [
    "/wwwroot/app/**/*.ts",
    "/typings/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

如果我使用它(而不是用于配置打字稿选项的默认 Visual Studio 内置功能),那么我的打字定义没有被读取,我得到 angular 没有定义。

当我使用它时,请注意它说找不到名称 angular

当我不使用它时

如果我拖动类型定义 /// 然后它工作。问题是 tsconfig 是如何改变类型定义的发现能力的?

【问题讨论】:

    标签: typescript visual-studio-2015 typescript-typings tsconfig


    【解决方案1】:

    您不能在 tsconfig.json 中使用 glob 模式 - 您的 files 部分无效。如果你想使用它,你应该一个一个地指定文件。另外exclude 不能与files 一起使用(如果两者都指定,files 将获胜)。

    您的问题的解决方案 - 只需 删除 files 部分。请参阅documentation 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-03
      • 2021-07-08
      • 2013-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多