Description
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:
private get supportsOffscreenCanvas(): boolean {
return HTMLCanvasElement.prototype.transferControlToOffscreen !== undefined;
}
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.
let offscreenCanvas = canvas.transferControlToOffscreen();
🙁 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.