Skip to content
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

Regression: The overload getContext("experimental-webgl") was deleted a month ago #33255

Closed
evanw opened this issue Sep 5, 2019 · 2 comments
Closed

Comments

@evanw
Copy link
Contributor

evanw commented Sep 5, 2019

TypeScript Version: 3.6.2

Search Terms: WebGL, getContext, experimental-webgl, type definitions, lib.dom.d.ts

Code

const gl: WebGLRenderingContext = document.createElement('canvas').getContext('experimental-webgl')!;

Expected behavior:
No type errors.

Actual behavior:
I get a type error now:

foo.ts:1:7 - error TS2322: Type 'RenderingContext' is not assignable to type 'WebGLRenderingContext'.
  Type 'CanvasRenderingContext2D' is missing the following properties from type 'WebGLRenderingContext': drawingBufferHeight, drawingBufferWidth, activeTexture, attachShader, and 429 more.

1 const gl: WebGLRenderingContext = document.createElement('canvas').getContext('experimental-webgl')!;
        ~~

I discovered this because VSCode just updated. My project was working fine yesterday but now my project no longer compiles without type errors. The latest version of VSCode includes TypeScript 3.6.2, which has this error in the standard type definitions.

Playground Link:
N/A (I can't reproduce on the playground)

Related Issues:
This has already been reported in 2015: #5773. It was fixed in 2016 here: microsoft/TypeScript-DOM-lib-generator#56. It looks like this fix was reverted by #32578 a month ago.

@AviVahl
Copy link

AviVahl commented Sep 5, 2019

"The experimental-webgl context is gone. Instead, use webgl or webgl2."

https://devblogs.microsoft.com/typescript/announcing-typescript-3-6/

@evanw
Copy link
Contributor Author

evanw commented Sep 5, 2019

Ah, I see. Ok then I'll close this since it was intentional change.

Won't that always be necessary for older browsers though? I thought it was needed in older versions of Edge at least. It's no big deal since I can just cast to any. Just curious why it was removed.

@evanw evanw closed this as completed Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants