Skip to content

Commit 2daf422

Browse files
author
Micah Zoltu
committed
Makes the ontouch* events on window optional.
Browsers without touch support (e.g., Firefox/Chrome on desktop) will not have `ontouch*` events defined on `window`, so the current type definition is not correct. package-lock was out of date and auto-updated on `npm install`. I can roll that back if desired.
1 parent 85ea749 commit 2daf422

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

baselines/dom.generated.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6096,10 +6096,10 @@ interface GlobalEventHandlers {
60966096
*/
60976097
ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
60986098
ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
6099-
ontouchcancel: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6100-
ontouchend: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6101-
ontouchmove: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6102-
ontouchstart: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6099+
ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6100+
ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6101+
ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
6102+
ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
61036103
ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
61046104
ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
61056105
ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;

inputfiles/overridingTypes.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@
129129
"property": {
130130
"onerror": {
131131
"override-type": "OnErrorEventHandler"
132+
},
133+
"ontouchcancel": {
134+
"required": 0
135+
},
136+
"ontouchend": {
137+
"required": 0
138+
},
139+
"ontouchmove": {
140+
"required": 0
141+
},
142+
"ontouchstart": {
143+
"required": 0
132144
}
133145
}
134146
}

src/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
617617
else {
618618
pType = convertDomTypeToTsType(p);
619619
}
620-
const requiredModifier = p.required === undefined || p.required === 1 ? "" : "?";
620+
const requiredModifier = p.required === undefined || p.required === 1 || prefix ? "" : "?";
621621
pType = p.nullable ? makeNullable(pType) : pType;
622622
const readOnlyModifier = p["read-only"] === 1 && prefix === "" ? "readonly " : "";
623623
printer.printLine(`${prefix}${readOnlyModifier}${p.name}${requiredModifier}: ${pType};`);

0 commit comments

Comments
 (0)