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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3245,7 +3245,7 @@ declare var CacheStorage: {

interface CanvasCompositing {
globalAlpha: number;
globalCompositeOperation: string;
globalCompositeOperation: GlobalCompositeOperation;
}

interface CanvasDrawImage {
Expand Down Expand Up @@ -17757,6 +17757,7 @@ type FontFaceSetLoadStatus = "loaded" | "loading";
type FullscreenNavigationUI = "auto" | "hide" | "show";
type GamepadHapticActuatorType = "vibration";
type GamepadMappingType = "" | "standard" | "xr-standard";
type GlobalCompositeOperation = "color" | "color-burn" | "color-dodge" | "copy" | "darken" | "destination-atop" | "destination-in" | "destination-out" | "destination-over" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "lighter" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | "source-atop" | "source-in" | "source-out" | "source-over" | "xor";
type HdrMetadataType = "smpteSt2086" | "smpteSt2094-10" | "smpteSt2094-40";
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
type IDBRequestReadyState = "done" | "pending";
Expand Down
31 changes: 31 additions & 0 deletions inputfiles/addedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,37 @@
"value": [
"inprogress"
]
},
"GlobalCompositeOperation": {
"name": "GlobalCompositeOperation",
"value": [
"source-over",
"source-in",
"source-out",
"source-atop",
"destination-over",
"destination-in",
"destination-out",
"destination-atop",
"lighter",
"copy",
"xor",
"multiply",
"screen",
"overlay",
"darken",
"lighten",
"color-dodge",
"color-burn",
"hard-light",
"soft-light",
"difference",
"exclusion",
"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

]
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions inputfiles/overridingTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@
}
}
},
"CanvasCompositing": {
"properties": {
"property": {
"globalCompositeOperation": {
"type": "GlobalCompositeOperation"
}
}
}
},
"Body": {
"properties": {
"property": {
Expand Down