Skip to content

Node.parentElement should be maybe-null #11113

Closed
@evmar

Description

@evmar

lib.dom.ts defines Node.parentElement as never-null:
https://github.com/Microsoft/TypeScript/blob/95c3eccbe9f3f7e1857ce157d437e6b80b3c9c6f/lib/lib.dom.d.ts#L8749

However, it's a pretty common pattern to write loops like

while (n.parentElement != null) {
  // [...]
  n = n.parentElement;
}

to walk up the node tree.

Also parentNode, previousSibling, nextSibling, firstChild, lastChild... (?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeBugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions