TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
MutationRecord addedNodes & removedNodes should be typed as NodeList<Element>
In the spirit of https://github.com/microsoft/TypeScript/issues/38616 MutationRecord's addedNodes & removedNodes props should be typed as NodeList<Element>
In TS ^4.1.3 they are NodeList which gives me TS2339: Property 'classList' does not exist on type 'Node' error when trying to access one of its members' Element-related properties:

But I get TextNodes with this API.
This is more a problem with dynamic type change with the ?. operator.
I was able to get around this error by doing the following:
mutations.forEach({ target }) => {
if (target instanceof HTMLElement) {
console.log(target.classList);
}
});
@instil-spencerc cool but we need a fix, not a work around