0
    let mdNode = document.querySelector('#test')

    let targetNode: HTMLElement = <HTMLElement>Array.from(mdNode.childNodes).find(childNode => {
      if (childNode.nodeType === 1) {
        return childNode.innerHTML.indexOf('aaaa') !== -1
      }
    })

It tips error TS2339: Property 'innerHTML' does not exist on type 'ChildNode'.

The nodeType === 3 dose haven't innerHTML property, but the nodeType ===1 have the innerHTML. What should I change to fix this error.

Eriice
  • 147
  • 1
  • 7
  • I use some hack way to avoid it. That is change to `childNode['innerHTML']`. But are there some elegant way to figure out that? – Eriice Apr 15 '19 at 12:46
  • Why do you have to write this at all? What is it you are trying to accomplish? There might be a "pure"/native angular way to solve the same problem. Please share the component and template code along with a description of the problem you are trying to solve. – Igor Apr 15 '19 at 12:52
  • @Igor I try to get the node which include target string. [Some similar question](https://stackoverflow.com/questions/6520192/how-to-get-the-text-node-of-an-element) – Eriice Apr 15 '19 at 14:34

0 Answers0