打字稿错误-getElementsByTagName()返回NodeListOf <element>而不是HTMLCollectionOf <element>

时间:2019-01-24 07:26:53

标签: typescript resharper webstorm jetbrains-ide

根据lib.dom.d.ts,getElementsByTagName()将返回HTMLCollectionOf,但是我运行以下代码行:

var lessonList: HTMLCollectionOf<Element> = xmlDoc.getElementsByTagName("lesson");

我将收到此错误

TS 2322 Type NodeListOf <Element> is not assignable to type HTMLCollectionOf <Element> site:stackoverflow.com

顺便说一句,我正在使用Webstorm 2018.3

0 个答案:

没有答案