question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google feedback on TypeScript 4.4-beta

See original GitHub issue

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%

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:34
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
goremikinscommented, Aug 27, 2021

Following the review from @h-joo , it looks wrong to remove getSelection, elementFromPoint and elementsFromPoint methods from DocumentOrShadowRoot. Consider the scenario when the developer needs to get an element inside ShadowDom from coordinates, the only way to get those is by calling ShadowRoot.elementFromPoint.

These methods are supported by major browsers and described in https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot.

2reactions
RoXuScommented, Sep 3, 2021

we use getSelection from shadowRoot since long time and now we get this error:

image

(with lit)

Read more comments on GitHub >

github_iconTop Results From Across the Web

./orta@mastodon.social --degrowth -- on Twitter: "@Google ...
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...
Read more >
Update TypeScript to version 4.3.5 [devtools ... - Google Groups
Update TypeScript to version 4.3.5 [devtools/devtools-frontend : main] ... Patch set 1:Code-Review +1 ... Why not go to the 4.4 beta yet? :)....
Read more >
TypeScript 4.5 is out with improvements and new snippet ...
TypeScript 4.4 brings control flow analysis improvement. TypeScript already had the ability to check whether a variable had a more specific ...
Read more >
Preface - Effective TypeScript [Book] - O'Reilly
In the spring of 2016, I visited my old coworker Evan Martin at Google's San Francisco office and ... All samples were verified...
Read more >
TypeScript 4.4 Brings Performance Boosts - Devstyler.io
Google accepted Autoscaling for Cloud Bigtable to Optimize Costs ... The TypeScript 4.4 beta can be accessed through NuGet or via NPM:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found