Visual studio TypeScript错误:";找不到名称“;在VisualStudio中
我已经看到了很多关于这方面的帖子和讨论,但我无法解决这个问题Visual studio TypeScript错误:";找不到名称“;在VisualStudio中,visual-studio,typescript,visual-studio-2015,tsconfig,Visual Studio,Typescript,Visual Studio 2015,Tsconfig,我已经看到了很多关于这方面的帖子和讨论,但我无法解决这个问题 打字的目的之一是避免使用标记,对吗 但如果我不使用它,Visual Studio会抱怨: 一旦我引用了browser.d.ts,Visual Studio就会停止抱怨 这是我的tsconfig: { "compilerOptions": { "noImplicitAny": false, "noEmitOnError": true, "removeComments": false, "source
打字的目的之一是避免使用
标记,对吗
但如果我不使用它,Visual Studio会抱怨:
一旦我引用了browser.d.ts
,Visual Studio就会停止抱怨
这是我的tsconfig
:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"files": [
],
"exclude": [
"node_modules",
"wwwroot"
]
}
我还尝试按照建议从tsconfig
中删除“files”
属性,但如果这样做,则会在打字环境文件夹中的其他typescript文件中出现编译错误
代码运行正常,但我想了解我是否做错了什么,或者这是否是Visual Studio的问题。对于那些将来可能会遇到相同问题的人:
我解决了这个问题。秘密在于从tsconfig
中排除“files”
属性,并在“excluded”
部分添加文件夹“typings”
tsconfig
现在应该如下所示:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"typings",
"node_modules",
"wwwroot"
]
}
在我的例子中,我修复了在tsconfig.json
中的“types”
部分添加“jasmine”
。像这样:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"typings",
"node_modules",
"wwwroot"
],
"types": ["jasmine"]
}