Skip to content

Google feedback on TypeScript 4.4-beta #45047

Closed
@h-joo

Description

@h-joo

Feedback to the TypeScript team for TypeScript 4.4-beta

This GitHub issue contains feedback on the TS 4.4-beta release from the team
that is responsible for keeping Google's internal software working with the
latest version of TypeScript.

During the 4.4-beta migration, we have ran into some issues. Especially some
changes made in lib.dom.d.ts will make it diffilcut for Google to migrate. We've
listed the breaking changes which we weren't able to easily migrate in the
following section.

Breakages which are complicated to migrate

Each subsection in this section contains a diagnosis of the breakage and a link
to the github issue if available.

canvas API changes in WebGL

WebGL2RenderingContext no longer seems to have a .canvas field, however the
WebGLRenderingContext does have one. TS now doesn't list one on either API.
There seems to be a github issue
related to the failure, and it seems it has been fixed already.

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):

Compare(DOMMatrix):

Compare(DOMRect):

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.

Offscreen Rendering API changes

OffscreenCanvas still exists, but it's marked as deprecated. Though it is no
longer a value, i.e. code calling new OffscreenCanvas no 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.

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.

ChildNode interface changes

In 4.4, ChildNode no longer extends Node. This seems like a bug.

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.

Impact summary (trivial fix unavailable)

Change description Libraries affected
type of ariaLabel is string rather than string/null 0.079%
ShadowRoot interface changes 0.034%
OffscreenCanvas Rendering API changes 0.014%
Removed Types 0.009%
Newly readonly attributes 0.008%
DocumentOrShadowRoot interface changes 0.005%
ChildNode interface changes 0.004%
canvas API changes 0.004%

Impact summary (trivial fix available)

Change description Libraries affected
window.parent nullability changes 0.088%
misc and other changes 0.088%
Various Media Related API changes 0.019%
window.location.reload interface changes 0.014%
Navigator API changes 0.012%
Promise always evaluate to true or false 0.011%
CustomElementConstructor interface changes 0.010%
Property has no initializer 0.008%
Infinite depth type inference 0.002%
property specified more than once in object literal 0.002%
document.createTreeWalker interface changes 0.001%

Metadata

Metadata

Assignees

No one assigned

    Labels

    DiscussionIssues which may not have code impact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions