Skip to content

NodeListOf#item misses return type "null" #1261

Open
@danielrentz

Description

@danielrentz

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions