Repository navigation
Google Feedback on 4.4 Beta #1067
Description
Opening on the behalf of Hana Joo (@h-joo) from microsoft/TypeScript#45047:
Readonly attributes in DOMPoint, DOMMatrix, DOMRect
Some properties of DOMPoint, DOMMatrix, DOMRect became readonly, and this no
longer match the specification. This is because these types no longer override
properties from the extended types to be read/write.Compare(DOMPoint):
- https://github.com/microsoft/TypeScript/blob/release-4.3/lib/lib.dom.d.ts#L3979
- https://github.com/microsoft/TypeScript/blob/release-4.4/lib/lib.dom.d.ts#L3886
Compare(DOMMatrix):
- https://github.com/microsoft/TypeScript/blob/release-4.3/lib/lib.dom.d.ts#L3854
- https://github.com/microsoft/TypeScript/blob/release-4.4/lib/lib.dom.d.ts#L3783
Compare(DOMRect):
- https://github.com/microsoft/TypeScript/blob/release-4.3/lib/lib.dom.d.ts#L4026
- https://github.com/microsoft/TypeScript/blob/release-4.4/lib/lib.dom.d.ts#L3929
Removed Types
SpeechRecognition, RTCError got removed from lib.dom.d.ts. There are existing
code which use this API, and it would be difficult to migrate without proper
type support either from the compiler or from definitelyTyped.
- https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognitionEvent
- https://developer.mozilla.org/en-US/docs/Web/API/RTCError
Offscreen Rendering API changes
OffscreenCanvas still exists, but it's marked as deprecated. Though it is no
longer a value, i.e. code callingnew OffscreenCanvasno longer works, it's
just an interface. We think this might be unintentional. Though, we would still
be able to migrate via referring to the types defined in
DefinitelyTyped.
- https://github.com/microsoft/TypeScript/blob/release-4.3/lib/lib.dom.d.ts#L11087
- https://github.com/microsoft/TypeScript/blob/release-4.4/lib/lib.dom.d.ts#L10832
ShadowRoot interface changes
ShadowRoot is a subtype of DocumentFragment. DocumentFragment has a
getElementById which returns HTMLElement. In 4.4-beta, DocumentFragment no
longer defines its own getElementById method, meaning
HTMLElement.prototype.shadowRoot.getElementById returns Element, not
HTMLElement. This causes hundreds of breakages of code using shadowRoot.
- https://github.com/microsoft/TypeScript/blob/release-4.3/lib/lib.dom.d.ts#L4985
- https://github.com/microsoft/TypeScript/blob/release-4.4/lib/lib.dom.d.ts#L4717
ChildNode interface changes
In 4.4, ChildNode no longer extends Node. This seems like a bug.
- https://github.com/microsoft/TypeScript/blob/release-4.3/lib/lib.dom.d.ts#L3531
- https://github.com/microsoft/TypeScript/blob/release-4.4/lib/lib.dom.d.ts#L3487
DocumentOrShadowRoot interface changes
DocumentOrShadowRoot no longer has getSelection, elementFromPoint,
elementsFromPoint, caretFromRange. We also couldn't find in the repo whether
this was intentional or not.
Activity
h-joo commentedon Jul 16, 2021
Thank you 😊
In the meanwhile we've found two more types which we missed to added to
Removed Typessection, which areVRDisplayandMediaStreamError.saschanaz commentedon Jul 16, 2021
It's my fault 😬, will fix it.
Those are Chrome-only things, while
SpeechRecognitionis supported by Chrome and Safari but only withwebkitprefix.OffscreenCanvasseems like a good candidate for additional type package as suggested in #1023, but for now I guess it should be added to DefinitelyTyped?SpeechRecognitionmiiiight be able to be added back, but I would also prefer DefinitelyTyped for this. 🤔The current type is "correct", but since
Document.getElementByIdis already customized for easier use, I'll do the same there.It's a mixin interface implemented by some Node interfaces. The correct way to receive Nodes that can be children is
ChildNode & Node, just likeParentNode & Nodefor Nodes that can be parents.Restore writeable attribute of geometry interfaces
Restore writeable attribute of geometry interfaces (#1070)
h-joo commentedon Aug 24, 2021
Thank you Kagami Sascha Rosylight (@saschanaz) and Daniel Rosenwasser (@DanielRosenwasser) for the help. We've checked TS4.4-rc and I've seen much reduced breakages, and most of the remaining breakages it seems that we can fix it via DefinitelyTyped, or the use should be removed as it's vendor specific or deprecated.
Though we still see some failures with respect to removed types which are things below :
as Kagami Sascha Rosylight (@saschanaz) mentioned that
SpeechRecognitionEventmight be added to DT, I was wondering if there are any plans, I guess I can also try adding that myself.For the RTCError, I am uncertain if it was intentional, but from this commit it seems the use of RTCErrorEvent seems to be commented out intentionally?
saschanaz commentedon Aug 24, 2021
No immediate plan, you are free to do that.
RTCError and RTCErrorEvent are excluded as they are also currently Chrome only. Maybe @types/webrtc should include them instead?
h-joo commentedon Aug 24, 2021
Great, now all makes sense. Thank you for your help!!
orta commentedon Aug 27, 2021
Looking at
DocumentOrShadowRootlosinggetSelection, elementFromPoint, elementsFromPoint, caretFromRange:DocumentOrShadowRootis a mixin which is filled in by a bunch of specsDocumentOrShadowRootshould have those properties (that I've found), onlyDocumenthas them (which you can see in the dom.d.ts today)The MDN docs for ShadowRoot specifically calls these out as being red/not available in their docs, which I assume means that they have been removed in a spec, and/or browsers : https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot#methods
saschanaz commentedon Aug 27, 2021
Seems that
elementFromPointandelementsFromPointshould be restored since those are supported everywhere.andrewbranch commentedon Aug 27, 2021
The red links are tooltipped as
The browser support matrix for
elementFromPointandelementsFromPointlooks pretty complete (just IE missing support).Haprog commentedon Dec 13, 2021
This used to be declared in the Shadow DOM spec, but there's apparently some ongoing(?) work related to migrating that spec to other specs. See my related comment here: WICG/webcomponents#661 (comment)
It's weird to me that those are not anymore shown in any live spec to be part of DocumentOrShadowRoot, but to me that looks like an accident also. I'm pretty sure they were not intentionally being dropped from specs.