Type ‘NamedNodeMap’必须具有返回迭代器的'[Symbol.iterator]()’方法。

huangapple go评论59阅读模式
英文:

Type 'NamedNodeMap' must have a '[Symbol.iterator]()' method that returns an iterator

问题

我正在使用最新的 TypeScript(5.1.3)构建项目,但编译器报错:

Type 'NamedNodeMap' must have a '[Symbol.iterator]()' method that returns an iterator

我想要迭代Element.attributes。有没有什么选项我漏掉了?在 Playground 上我无法复现这个问题(正如预期的,因为这个问题已经在2018年被修复)。

英文:

I've got a project building with the latest TS (5.1.3) but the compiler is complaining with

Type 'NamedNodeMap' must have a '[Symbol.iterator]()' method that returns an iterator.

I'm looking to iterate over Element.attributes. Any idea what option I'm missing ? I can't reproduce this on the playground (as expected since this issue has been fixed in 2018)

答案1

得分: 0

我在tsconfig的lib中缺少了dom.iterable

英文:

I was missing dom.iterable in the tsconfig lib.

huangapple
  • 本文由 发表于 2023年6月30日 01:54:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76583513.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定