diff --git a/baselines/audioworklet.generated.d.ts b/baselines/audioworklet.generated.d.ts index 1d5a8086b..4d5273eca 100644 --- a/baselines/audioworklet.generated.d.ts +++ b/baselines/audioworklet.generated.d.ts @@ -684,9 +684,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index bcae88127..5c9706a2f 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -16391,9 +16391,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/serviceworker.generated.d.ts b/baselines/serviceworker.generated.d.ts index f848ec0fd..7c9ebd472 100644 --- a/baselines/serviceworker.generated.d.ts +++ b/baselines/serviceworker.generated.d.ts @@ -3761,9 +3761,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/sharedworker.generated.d.ts b/baselines/sharedworker.generated.d.ts index f2bb37e7a..c8865b37b 100644 --- a/baselines/sharedworker.generated.d.ts +++ b/baselines/sharedworker.generated.d.ts @@ -3650,9 +3650,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.5/audioworklet.generated.d.ts b/baselines/ts5.5/audioworklet.generated.d.ts index 1d5a8086b..4d5273eca 100644 --- a/baselines/ts5.5/audioworklet.generated.d.ts +++ b/baselines/ts5.5/audioworklet.generated.d.ts @@ -684,9 +684,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index d6a806977..d519d0f87 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -16371,9 +16371,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.5/serviceworker.generated.d.ts b/baselines/ts5.5/serviceworker.generated.d.ts index f848ec0fd..7c9ebd472 100644 --- a/baselines/ts5.5/serviceworker.generated.d.ts +++ b/baselines/ts5.5/serviceworker.generated.d.ts @@ -3761,9 +3761,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.5/sharedworker.generated.d.ts b/baselines/ts5.5/sharedworker.generated.d.ts index f2bb37e7a..c8865b37b 100644 --- a/baselines/ts5.5/sharedworker.generated.d.ts +++ b/baselines/ts5.5/sharedworker.generated.d.ts @@ -3650,9 +3650,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.5/webworker.generated.d.ts b/baselines/ts5.5/webworker.generated.d.ts index 37c8fd5ca..4027629be 100644 --- a/baselines/ts5.5/webworker.generated.d.ts +++ b/baselines/ts5.5/webworker.generated.d.ts @@ -4335,9 +4335,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 37c8fd5ca..4027629be 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -4335,9 +4335,9 @@ interface MessageEventTargetEventMap { interface MessageEventTarget { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/message_event) */ - onmessage: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessage: ((this: this, ev: MessageEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event) */ - onmessageerror: ((this: MessageEventTarget, ev: MessageEvent) => any) | null; + onmessageerror: ((this: this, ev: MessageEvent) => any) | null; addEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessageEventTarget, ev: MessageEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 35d52d3dc..07518e6c2 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -40,7 +40,14 @@ } } }, + "AbstractWorker": { + "concreteThisParameter": true + }, + "WindowEventHandlers": { + "concreteThisParameter": true + }, "GlobalEventHandlers": { + "concreteThisParameter": true, "events": { "event": [ { diff --git a/src/build/emitter.ts b/src/build/emitter.ts index 0760d7dd7..a4ab6e6d2 100644 --- a/src/build/emitter.ts +++ b/src/build/emitter.ts @@ -770,6 +770,9 @@ export function emitWebIdl( function emitEventHandlerThis(prefix: string, i: Browser.Interface) { if (prefix === "") { + if (i.mixin && !i.concreteThisParameter) { + return `this: this, `; + } return `this: ${nameWithForwardedTypes(i)}, `; } else { return polluter ? `this: ${polluter.name}, ` : ""; diff --git a/src/build/types.d.ts b/src/build/types.d.ts index b3c68a68f..ed0e45904 100644 --- a/src/build/types.d.ts +++ b/src/build/types.d.ts @@ -181,6 +181,7 @@ export interface Interface { overrideExposed?: string; tags?: string; "implicit-this"?: 1; + concreteThisParameter?: boolean; noInterfaceObject?: boolean; global?: string; typeParameters?: TypeParameter[];