我是一只试图学习新技巧的老狗(npm,TypeScript等).我正在使用Visual Studio 2017和TypeScript 2.5(项目设置为“最新”).我有一个非常基本的.NET Core 2.0项目,我刚刚开始研究并将@ types /
jquery(3.2.12)添加到我的项目中,但它继续抱怨无法找到’Iterable’.我已经阅读了很多关于这个主题的帖子以及如何修复它,包括:
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17239
TS-2304 Error – can not find name ‘Iterable’ in TypeScript while importing “jquery” in “.ts” file
我当前的tsconfig.json包含:
{
"compilerOptions": {
"lib": [
"dom",
"es5",
"es2015.iterable"
],
"target": "es5"
},
"exclude": [
"node_modules"
]
}
我已经尝试过libs目标的每个排列都无济于事.我可以得到各种其他错误但是这个错误永远不会消失.我花了更多的时间来尝试让TypeScript工作,而不是用普通的JavaScript编写模块.
这是.NET Core项目/模板问题吗?如何判断IDE正在查看我的tsconfig.json文件(项目树中没有其他此类文件).任何帮助,将不胜感激.
最佳答案 我有一个类似的问题,我不得不在我的tsconfig.json中添加include部分,我解决了这个错误.我有jQuery的3.2.1版本和@ types / jquery的3.2.12版本.
{
"compileOnSave": true,
"compilerOptions": {
"lib": [ "dom", "es2015" ],
"module": "commonjs",
"sourceMap": true,
"strict": true,
"target": "es5"
},
"include": [
"./Scripts/TypeScript/*"
],
"exclude": [
"node_modules",
"wwwroot"
]
}