diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 5f1d24151..22161016b 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -6096,10 +6096,10 @@ interface GlobalEventHandlers { */ ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null; ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null; - ontouchcancel: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; - ontouchend: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; - ontouchmove: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; - ontouchstart: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; + ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; + ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; + ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; + ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; @@ -19886,10 +19886,10 @@ declare var onsuspend: ((this: Window, ev: Event) => any) | null; */ declare var ontimeupdate: ((this: Window, ev: Event) => any) | null; declare var ontoggle: ((this: Window, ev: Event) => any) | null; -declare var ontouchcancel: ((this: Window, ev: TouchEvent) => any) | null; -declare var ontouchend: ((this: Window, ev: TouchEvent) => any) | null; -declare var ontouchmove: ((this: Window, ev: TouchEvent) => any) | null; -declare var ontouchstart: ((this: Window, ev: TouchEvent) => any) | null; +declare var ontouchcancel: ((this: Window, ev: TouchEvent) => any) | null | undefined; +declare var ontouchend: ((this: Window, ev: TouchEvent) => any) | null | undefined; +declare var ontouchmove: ((this: Window, ev: TouchEvent) => any) | null | undefined; +declare var ontouchstart: ((this: Window, ev: TouchEvent) => any) | null | undefined; declare var ontransitioncancel: ((this: Window, ev: TransitionEvent) => any) | null; declare var ontransitionend: ((this: Window, ev: TransitionEvent) => any) | null; declare var ontransitionrun: ((this: Window, ev: TransitionEvent) => any) | null; diff --git a/inputfiles/overridingTypes.json b/inputfiles/overridingTypes.json index 1084ac750..deee4b5fd 100644 --- a/inputfiles/overridingTypes.json +++ b/inputfiles/overridingTypes.json @@ -129,6 +129,18 @@ "property": { "onerror": { "override-type": "OnErrorEventHandler" + }, + "ontouchcancel": { + "required": 0 + }, + "ontouchend": { + "required": 0 + }, + "ontouchmove": { + "required": 0 + }, + "ontouchstart": { + "required": 0 } } } diff --git a/src/emitter.ts b/src/emitter.ts index 2c129ad2c..0e4fdddee 100644 --- a/src/emitter.ts +++ b/src/emitter.ts @@ -617,8 +617,12 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) { else { pType = convertDomTypeToTsType(p); } - const requiredModifier = p.required === undefined || p.required === 1 ? "" : "?"; + const required = p.required === undefined || p.required === 1; + const requiredModifier = required || prefix ? "" : "?"; pType = p.nullable ? makeNullable(pType) : pType; + if (!required && prefix) { + pType += " | undefined" + } const readOnlyModifier = p["read-only"] === 1 && prefix === "" ? "readonly " : ""; printer.printLine(`${prefix}${readOnlyModifier}${p.name}${requiredModifier}: ${pType};`); }