Angular 类型';HTML集合';必须有一个';[Symbol.iterator]()';方法,该方法在指令中返回迭代器

Angular 类型';HTML集合';必须有一个';[Symbol.iterator]()';方法,该方法在指令中返回迭代器,angular,iterator,directive,htmlcollection,Angular,Iterator,Directive,Htmlcollection,指令中有一个映射向我显示错误代码TS2488类型“HTML集合”必须有一个返回迭代器的“[Symbol.iterator]”方法 我的地图: map( ([headRow, bodyRows]: [HTMLTableRowElement, HTMLCollectionOf<HTMLTableRowElement>]) => [ [...headRow.children].map(headerCell => headerCell.textContent), //

指令中有一个映射向我显示错误代码
TS2488类型“HTML集合”必须有一个返回迭代器的“[Symbol.iterator]”方法

我的地图:

map(
  ([headRow, bodyRows]: [HTMLTableRowElement, HTMLCollectionOf<HTMLTableRowElement>]) => [
    [...headRow.children].map(headerCell => headerCell.textContent), // First issue
    [...bodyRows].map(row => [...row.children]) // Second issue
  ]
),
map(
([Headlow,bodyRows]:[HTMLTableRowElement,HTMLCollectionOf])=>[
[…headRow.children].map(headerCell=>headerCell.textContent),//第一期
[…bodyRows].map(row=>[…row.children])//第二期
]
),

我如何最好地处理这个问题?有什么建议吗?

HTMLCollection不可编辑,但您可以通过在HTML元素上使用“any”来忽略它

          ([headRow, bodyRows]: [
            HTMLTableRowElement,
            HTMLCollectionOf<HTMLTableRowElement>
          ]) => [
            [...(<any>headRow.children)].map(
              (headerCell) => headerCell.textContent
            ),
            [...(<any>bodyRows)].map((row) => [...row.children])```
([Headlow,bodyRows]:[
HTMLTableRowElement,
HTMLCollectionOf
]) => [
[…(头枕.儿童)].地图(
(headerCell)=>headerCell.textContent
),
[…(bodyRows)].map((row)=>[…row.children])```