打字稿错误:“找不到名称"在 Visual Studio 中 [英] TypeScript error: "Cannot find name" in Visual Studio
问题描述
我看到了很多关于这个的话题和讨论,但我没有解决这个问题.
一旦我引用了 browser.d.ts
,Visual Studio 就会停止抱怨.
这是我的tsconfig
:
<代码>{编译器选项":{noImplicitAny":假,noEmitOnError":真,删除评论":假,"sourceMap": 真,目标":es5"},文件":[],排除": [节点模块",wwwroot"]}
我还尝试按照建议从 tsconfig
中删除 "files"
属性此处,但如果我这样做,我会在类型环境文件夹内的其他打字稿文件中出现编译错误.
代码运行并且一切正常,但我想了解我是否做错了什么或者是 Visual Studio 问题.
就我而言,我修复了将 "jasmine"
添加到 tsconfig 中的
.像这样:"types"
部分.json
<代码>{编译器选项":{noImplicitAny":假,noEmitOnError":真,删除评论":假,"sourceMap": 真,目标":es5"},排除": ["打字",节点模块",wwwroot"],类型":[茉莉花"]}
I've seen a lot of threads and discussions about that but I'm not getting to fix the issue. This is my post from some days ago.
One of the purposes of typings
is to avoid the use of <reference>
tags, right?
But if I don't use it, Visual Studio complains:
Visual Studio stops complaining once I reference browser.d.ts
.
Here is my tsconfig
:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"files": [
],
"exclude": [
"node_modules",
"wwwroot"
]
}
I also tried removing the "files"
property from the tsconfig
as suggested here, but if I do this, I get compilation error in other typescript files inside the ambient folder of typings.
The code runs and all is fine, but I want to understand if I'm doing something wrong or if it's a Visual Studio problem.
In my case I fixed adding "jasmine"
into "types"
section in tsconfig.json
. Like this:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"typings",
"node_modules",
"wwwroot"
],
"types": ["jasmine"]
}
这篇关于打字稿错误:“找不到名称"在 Visual Studio 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!