Skip to content

Commit 95908c0

Browse files
sktbrdclaude
andcommitted
fix(e2e): type the getContext override so next build passes
The webgl-fallback spec's interceptor assigned a generic function over the DOM lib's per-id getContext overloads — tsc (and therefore next build) rejected it, which would have failed the production deploy of the very PR it guards. Assign through the original's own type; runtime passthrough unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b2ab9cb commit 95908c0

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/e2e/webgl-fallback.spec.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@ import { expect, test } from "@playwright/test";
1313
function disableWebGL(page: import("@playwright/test").Page) {
1414
return page.addInitScript(() => {
1515
const original = HTMLCanvasElement.prototype.getContext;
16-
HTMLCanvasElement.prototype.getContext = function (id: string, ...rest: unknown[]) {
16+
// The DOM lib types getContext as per-id overloads; a generic interceptor
17+
// cannot satisfy them, so the override is assigned through the original's
18+
// own type. Runtime behavior is untouched passthrough for non-WebGL ids.
19+
HTMLCanvasElement.prototype.getContext = function (
20+
this: HTMLCanvasElement,
21+
id: string,
22+
...rest: unknown[]
23+
) {
1724
if (id === "webgl" || id === "webgl2" || id === "experimental-webgl") return null;
18-
// @ts-expect-error - passthrough to the untouched 2d/bitmaprenderer contexts
19-
return original.call(this, id, ...rest);
20-
};
25+
return (original as (this: HTMLCanvasElement, ...a: unknown[]) => unknown).call(
26+
this,
27+
id,
28+
...rest,
29+
);
30+
} as typeof HTMLCanvasElement.prototype.getContext;
2131
});
2232
}
2333

0 commit comments

Comments
 (0)