-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTMLCanvasElement.transferControlToOffscreen() removed from lib.dom.d.ts #45745
Comments
Having experimental functions with bad support in the standard library is something TypeScript usually does not do. It leads to users using these functions without being aware of their experimental unsupported status. Removal of this function seems to be intended as per microsoft/TypeScript-DOM-lib-generator#1029:
If you depend on this you can use declaration merging to provide your own type definition for this function. |
It's experimental, but it's certainly not marked as deleted, and it has good support in Chromium browsers, and flagged support in Firefox. Other, upcoming APIs depend on offscreen canvases (like WebCodecs), so it seems strange to unilaterally remove it at this point. Furthermore, it's been in the type definition for a while - I see no logic in removing it now, and thus breaking the increasing amount of stuff that depends on it. |
Also, I notice that lib.dom.d.ts still has the definition for OffscreenCanvas in it. So, the decision to remove "transferControlToOffscreen" is inconsistent. Edit - no, I'm wrong. OffscreenCanvas isn't there in the latest version. (Juggling too many versions of lib.dom.d.ts) |
Is there any way to merge It looks really bad to say It's like saying "mammals or cats". It's redundant. |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
How is this working as intended? You broke peoples code! |
It’s not intentional that it was ever included in the first place, as it doesn’t meet our bar of spec/support for standard lib inclusion. The removal was documented ahead of time as @MartinJohns pointed out. We’re aware that 4.4 included more lib breaks than usual as we transitioned to a new process for generating them, and while we expect that the breakiness of 4.4 was a one-time pain associated with that transition, we’re having conversations about how we can do better with this in the future. That’s part of the motivation for a versioned |
Well, I guess the TS team hasn't learned how to use semver yet, the versioning standard that the vast majority of their own community uses. |
If that were true, then why didn't you release TS v5 instead? Why didn't you keep the APIs and add a new |
Do you know what's really annoying? When type errors (due to these lib.dom changes) start happening inside 3rd-party libs in your project's |
That would have made exactly no difference. TypeScript does not follow SemVer, for good reasons. Pretty much every TypeScript release contains breaking changes. |
FWIW, decoupling your lib versions is now possible in 4.5 with #45771. Any further comments on this issue will be about |
Slightly inconvenient, but I am just using
|
Bug Report
A recent change to lib.dom.d.ts has removed the HTMLCanvasElement.transferControlToOffscreen() method. Attempting to use this method now generates an error.
Even though not all browsers currently support offscreen canvases, checking for the existence of the method on the prototype is a good way of detecting whether offscreen canvases are supported. Eg:
This now generates an error by the Typescript compiler, as transferControlToOffscreen is no longer defined in the type definitions.
🔎 Search Terms
lib.dom.d.ts HTMLCanvasElement transferControlToOffscreen
🕗 Version & Regression Information
This issue was introduced in the latest version of VS Code, which is using Typescript 4.4.2.
The issue was introduced with this PR:
#44842
💻 Code
Attempting to reference the method transferControlToOffscreen() on HTMLCanvasElement generates errors.
🙁 Actual behavior
This generates an error because the method was removed from the DOM type definitions in the above referenced PR.
🙂 Expected behavior
I'd expect this not to generate an error, and continue to work as it did before.
The text was updated successfully, but these errors were encountered: