Skip to content

Commit af06295

Browse files
committed
Use OffscreenCanvas types library
Typescript (at least our current version) is confused about the OffscreenCanvas type. Installing the TS types for it resolves this issue. Should be reviewed once we update typescript version to 5.x, to see if those extra types are still needed
1 parent 8ef4848 commit af06295

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Diff for: frontend/js/src/explore/art-creator/utils.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ export async function svgToBlob(
3535

3636
let blob;
3737
if ("OffscreenCanvas" in window) {
38-
blob = await (canvas as OffscreenCanvas).convertToBlob({
38+
canvas = canvas as OffscreenCanvas;
39+
blob = await canvas.convertToBlob({
3940
type: encodeType,
4041
});
4142
} else {
4243
blob = await new Promise<Blob | null>((done, err) => {
4344
try {
44-
(canvas as HTMLCanvasElement).toBlob(done, encodeType);
45+
canvas = canvas as HTMLCanvasElement;
46+
canvas.toBlob(done, encodeType);
4547
} catch (error) {
4648
err(error);
4749
}

Diff for: package-lock.json

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"@types/jest": "^29.5.3",
134134
"@types/less": "^3.0.3",
135135
"@types/lodash": "^4.14.149",
136+
"@types/offscreencanvas": "^2019.7.3",
136137
"@types/react": "^18.0.25",
137138
"@types/react-dom": "^18.0.8",
138139
"@types/react-helmet": "^6.1.11",

0 commit comments

Comments
 (0)