const labelEl: HTMLElement = document.createElement('label')
const isElOfNeededType = (el: HTMLElement): boolean =>
["INPUT", "TEXTAREA"].includes(el.tagName);
let result
if (isElOfNeededType(labelEl.nextElementSibling)) {
result = true
}
Take a look at my code playground: here
- Can you help me understand why I'm receiving an error regarding
labelEl.nextElementSibling
?The argument of type 'Element' isn't compatible with the parameter type 'HTMLElement'
Isn't HTMLElement
supposed to extend Element
?
2. (not crucial, but some clarification would be appreciated) Why does TS playground show an error for [ ].includes
even though I've specified Config -> Target = esnext
?