Inconsistent types between Document scrollingElement and documentElement #60838
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Help Wanted
You can do this
Milestone
🔎 Search Terms
I think
document.scrollingElement
should be of typeDocument["documentElement"] | null
instead ofElement | null
. The spec (e.g. this and this) says that in standards modescrollingElement
returns the document root, which isdocument.documentElement
and in quirks mode returnsdocument.body
ornull
.document.body
is alwaysHTMLElement
(right?) In principle,document.documentElement
does not have to beHTMLElement
(and there's an open issue about this, #29052, but currentlyDocument.documentElement
is still defined asHTMLElement
, for some reason. So how comedocument.scrollingElement
is notHTMLElement | null
?🕗 Version & Regression Information
N/A
⏯ Playground Link
No response
💻 Code
// Your code here
🙁 Actual behavior
document.scrollingElement
is of typeElement | null
whereasdocument.documentElement
anddocument.body
are both of typeHTMLElement
.🙂 Expected behavior
The non-null part of
document.scrollingElement
should be the same type asdocument.documentElement
, which technically should beElement
, but ifdocument.documentElement
is left asHTMLElement
, as is currently, thendocument.scrollingElement
should also be this.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: