Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

superkelvint
Copy link

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
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
Author

superkelvint commented Jun 10, 2024 via email

@ondras
Copy link
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