Skip to content

Add more specific types for globalCompositeOperation #1206

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

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

dhaig
Copy link
Contributor

@dhaig dhaig commented Nov 23, 2021

Add types for CanvasRenderingContext2D.globalCompositeOperation, which is currently a string but should only accept certain values. The acceptable values come from MDN.

Reported as a bug in TypeScript's main repo: microsoft/TypeScript#34673

@ghost
Copy link

ghost commented Nov 23, 2021

CLA assistant check
All CLA requirements met.

@github-actions
Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

"hue",
"saturation",
"color",
"luminosity"

This comment was marked as outdated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, the spec actually defines more items when including <blend-mode>. Checking implementations...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec is confusing for this property. The extra enum items come from <blend-mode> but that also includes normal which browsers don't seem to support and which MDN doesn't list. I didn't include normal even though the spec technically would, I think that's in line with TypeScript's philosophy? Either way, the supported value source-over is what most people would assume normal does.

Copy link
Contributor

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder there should be two separate enums BlendMode and CompositeMode but for now, lgtm.

@saschanaz
Copy link
Contributor

lgtm, @github-actions?

@github-actions github-actions bot merged commit c1678fb into microsoft:main Nov 24, 2021
@github-actions
Copy link
Contributor

Merging because @saschanaz is a code-owner of all the changes - thanks!

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