closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

WebGL2RenderingContext should not extend WebGLRenderingContext

Open zbynek opened this issue 2 months ago • 2 comments

document.createElement("canvas").getContext("webgl2") instanceof WebGLRenderingContext

is false, so I think these contexts should not extend each other.

zbynek avatar Dec 04 '25 17:12 zbynek

One way to model this (the approach used by TypeScript) would be to define a non-existent common parent interface that includes all the common properties and their types.

blickly avatar Dec 06 '25 00:12 blickly

non-existent common parent interface

I was thinking something along those lines but I'm not sure if it should be an @interface, an @abstract @constructor (like BaseRenderingContext is for CanvasRenderingContext) or maybe a @record (given the note in https://github.com/google/closure-compiler/blob/master/externs/browser/html5.js#L475 ).

My goal is to use WebGL 2 from GWT through Elemental 2 which uses externs from this repo (https://github.com/google/elemental2/pull/181)

zbynek avatar Dec 06 '25 17:12 zbynek