Closed
Description
Line 4453 in 3b2bc85
Before the body
is ready, the value is null
.
PR: #44773
Also, although TypeScript now has ability for a getter to have a different type than a setter, it is still not possible to make the type properly. Based on Chromes behavior this is what describes it:
class Document {
get body(): HTMLBodyElement | HTMLFramesetElement | null { ... }
set body(value: HTMLBodyElement | HTMLFramesetElement) { ... }
}
however such a type is not allowed in TS 4.3.
If we follow the deprecation of HTMLFramesetElement
, which I think is a good idea, then the type would be this:
class Document {
get body(): HTMLBodyElement | null { ... }
set body(value: HTMLBodyElement) { ... }
}
but that still doesn't work.
Also, we could ignore the frameset deprecation and just write
class Document {
get body(): HTMLElement | null { ... }
set body(value: HTMLElement) { ... }
}
which also doesn't work.
This leads to runtime errors if someone is type-checking a <script>
tag before body
is ready.