gpt4 book ai didi

typescript - TS2304 : Build cannot find name iterable in @types/jquery

转载 作者:搜寻专家 更新时间:2023-10-30 21:00:09 24 4
gpt4 key购买 nike

我是一只尝试学习新技巧(npm、TypeScript 等)的老狗。我正在使用带有 TypeScript 2.5 的 Visual Studio 2017(项目设置为“最新”)。我有一个非常基本的 .NET Core 2.0 项目,我刚刚开始工作并将 @types/jquery (3.2.12) 添加到我的项目中,但它继续提示无法找到“Iterable”。我已经阅读了很多关于这个主题以及如何解决它的帖子,包括:

TypeScript error: node_modules/@types/three/three-core.d.ts(767,24): Error TS2304: Cannot find name '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 + target 的所有排列都无济于事。我可以得到各种其他错误,但这个核心错误永远不会消失。我花了更多的时间来尝试让 TypeScript 工作,而不是用普通的 JavaScript 编写模块。

这是 .NET Core 项目/模板问题吗?我怎么知道 IDE 正在查看我的 tsconfig.json 文件(项目树中没有其他此类文件)。任何帮助将不胜感激。

最佳答案

我有一个类似的问题,我不得不在我的 tsconfig.json 中添加 include 部分,我解决了这个错误。我有 3.2.1 版的 jQuery 和 3.2.12 版的@types/jquery

{
"compileOnSave": true,
"compilerOptions": {
"lib": [ "dom", "es2015" ],
"module": "commonjs",
"sourceMap": true,
"strict": true,
"target": "es5"
},
"include": [
"./Scripts/TypeScript/*"
],
"exclude": [
"node_modules",
"wwwroot"
]
}

关于typescript - TS2304 : Build cannot find name iterable in @types/jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46025458/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com