TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
NodeListOf#item misses return type "null"
Interface NodeList is correctly typed
interface NodeList {
item(index: number): Node | null;
}
but interface NodeListOf is missing the null type:
interface NodeListOf<TNode extends Node> extends NodeList {
item(index: number): TNode;
}
therefore TSC does not warn about missing null checks:
const node = document.childNodes.item(999999).firstChild;
~~Agree 👍🏻 open to changes here~~
Changed my mind after thinking about it in https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1268, this is probably too big of an ecosystem break