TypeScript错误:"找不到名字"在Visual Studio中

时间:2016-03-18 09:01:12

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

我已经看过很多线索和讨论,但我没有解决这个问题。 This is my post from some days ago

typings的目的之一是避免使用<reference>标签,对吗?

但如果我不使用它,Visual Studio会抱怨:

enter image description here

一旦我引用browser.d.ts,Visual Studio就会停止抱怨。

这是我的tsconfig

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
  },
  "files": [

  ],
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

我还尝试按照建议的here"files"删除tsconfig属性,但如果我这样做,我会在typings环境文件夹中的其他typescript文件中出现编译错误。

代码运行且一切正常,但我想了解我是否做错了或者它是否是Visual Studio问题。

2 个答案:

答案 0 :(得分:0)

对于将来可能遇到同样问题的人:

我解决了这个问题。秘诀是从"files"中排除tsconfig属性,并在"excluded"部分添加文件夹"typings"

tsconfig现在应该是这样的:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
  },
  "exclude": [
    "typings",
    "node_modules",
    "wwwroot"
  ]
}

答案 1 :(得分:0)

就我而言,我固定将"jasmine"添加到"types"的{​​{1}}部分中。像这样:

tsconfig.json