Skip to content

Fix compilation error in src/backend/image.ts that blob can be null#180

Open
superkelvint wants to merge 1 commit intoondras:masterfrom
superkelvint:master
Open

Fix compilation error in src/backend/image.ts that blob can be null#180
superkelvint wants to merge 1 commit intoondras:masterfrom
superkelvint:master

Conversation

@superkelvint
Copy link
Copy Markdown

Compilation error was:

src/backend/image.ts:31:56 - error TS2345: Argument of type 'Blob | null' is not assignable to parameter of type 'Blob | MediaSource'.
  Type 'null' is not assignable to type 'Blob | MediaSource'.

31      canvas.toBlob(blob => resolve(URL.createObjectURL(blob)), "image/png");
                                                          ~~~~


Found 1 error in src/backend/image.ts:31

@superkelvint superkelvint changed the title Fix compilation error that blob can be null Fix compilation error in src/backend/image.ts that blob can be null Jun 6, 2024
@ondras
Copy link
Copy Markdown
Owner

ondras commented Jun 10, 2024

Hi @superkelvint ,

thanks for the PR. Are you aware of a particular situation where the toBlob fails to export the canvas? As far as I know, this would only happen with unsupported image format (and based on my experiments, browser just simply coerce to image/png instead).

@superkelvint
Copy link
Copy Markdown
Author

superkelvint commented Jun 10, 2024 via email

@ondras
Copy link
Copy Markdown
Owner

ondras commented Jun 10, 2024

Well, if we think that there is no reason for toBlob to fail, then a simpler build fix would be something similar to

URL.createObjectURL(blob!)

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

Successfully merging this pull request may close these issues.

2 participants