Skip to content

Commit

Permalink
Missing type definitions for older versions of typescript (#15129)
Browse files Browse the repository at this point in the history
* Add globalThis definitions to draco

* Cannot build. Missing ImageEncodeOptions, VideoFrame, etc.
Fixes #14976

* avoid type duplication with ts lib
  • Loading branch information
RaananW committed May 23, 2024
1 parent baaf363 commit 562e53e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/dev/core/src/LibDeclarations/offscreenCanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ interface OffscreenCanvasEventMap {
contextrestored: Event;
}

interface ImageEncodeOptions {
quality?: number;
type?: string;
}

// These types are only needed for older versions of typescript.
// The BJS addition is only needed because otherwise it is a type duplicate definition
type OffscreenRenderingContextIdBJS = "2d" | "bitmaprenderer" | "webgl" | "webgl2" | "webgpu";
type OffscreenRenderingContextBJS = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;

interface OffscreenCanvas extends EventTarget {
/**
* These attributes return the dimensions of the OffscreenCanvas object's bitmap.
Expand Down Expand Up @@ -41,7 +51,7 @@ interface OffscreenCanvas extends EventTarget {
getContext(contextId: "bitmaprenderer", options?: any): ImageBitmapRenderingContext | null;
getContext(contextId: "webgl", options?: any): WebGLRenderingContext | null;
getContext(contextId: "webgl2", options?: any): WebGL2RenderingContext | null;
getContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | null;
getContext(contextId: OffscreenRenderingContextIdBJS, options?: any): OffscreenRenderingContextBJS | null;
/** Returns a newly created ImageBitmap object with the image in the OffscreenCanvas object. The image in the OffscreenCanvas object is replaced with a new blank image. */
transferToImageBitmap(): ImageBitmap;
addEventListener<K extends keyof OffscreenCanvasEventMap>(
Expand Down

0 comments on commit 562e53e

Please sign in to comment.