Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeListOf#item misses return type "null" #1261

Open
danielrentz opened this issue Feb 8, 2022 · 1 comment · May be fixed by #1268
Open

NodeListOf#item misses return type "null" #1261

danielrentz opened this issue Feb 8, 2022 · 1 comment · May be fixed by #1268

Comments

@danielrentz
Copy link

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;
@orta
Copy link
Contributor

orta commented Feb 16, 2022

Agree 👍🏻 open to changes here

Changed my mind after thinking about it in #1268, this is probably too big of an ecosystem break

@danielrentz danielrentz linked a pull request Feb 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants