File tree Expand file tree Collapse file tree 8 files changed +40
-20
lines changed
Expand file tree Collapse file tree 8 files changed +40
-20
lines changed Original file line number Diff line number Diff line change @@ -144,8 +144,12 @@ import { createContext } from "node:vm";
144144 bc . close ( ) ;
145145 bc . ref ( ) ;
146146 bc . unref ( ) ;
147- bc . onmessage = ( msg : unknown ) => { } ;
148- bc . onmessageerror = ( msg : unknown ) => { } ;
147+ bc . onmessage = ( msg ) => {
148+ msg ; // $ExpectType MessageEvent<any>
149+ } ;
150+ bc . onmessageerror = ( msg ) => {
151+ msg ; // $ExpectType MessageEvent<any>
152+ } ;
149153
150154 // Test global alias
151155 const bc2 = new BroadcastChannel ( "test" ) ;
Original file line number Diff line number Diff line change @@ -128,8 +128,12 @@ import { createContext } from "node:vm";
128128 bc . close ( ) ;
129129 bc . ref ( ) ;
130130 bc . unref ( ) ;
131- bc . onmessage = ( msg : unknown ) => { } ;
132- bc . onmessageerror = ( msg : unknown ) => { } ;
131+ bc . onmessage = ( msg ) => {
132+ msg ; // $ExpectType MessageEvent<any>
133+ } ;
134+ bc . onmessageerror = ( msg ) => {
135+ msg ; // $ExpectType MessageEvent<any>
136+ } ;
133137
134138 // Test global alias
135139 const bc2 = new BroadcastChannel ( "test" ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ declare module "worker_threads" {
5959 import { Readable , Writable } from "node:stream" ;
6060 import { ReadableStream , TransformStream , WritableStream } from "node:stream/web" ;
6161 import { URL } from "node:url" ;
62+ import { MessageEvent } from "undici-types" ;
6263 const isMainThread : boolean ;
6364 const parentPort : null | MessagePort ;
6465 const resourceLimits : ResourceLimits ;
@@ -525,18 +526,18 @@ declare module "worker_threads" {
525526 * ```
526527 * @since v15.4.0
527528 */
528- class BroadcastChannel {
529+ class BroadcastChannel extends EventTarget {
529530 readonly name : string ;
530531 /**
531532 * Invoked with a single \`MessageEvent\` argument when a message is received.
532533 * @since v15.4.0
533534 */
534- onmessage : ( message : unknown ) => void ;
535+ onmessage : ( message : MessageEvent ) => void ;
535536 /**
536537 * Invoked with a received message cannot be deserialized.
537538 * @since v15.4.0
538539 */
539- onmessageerror : ( message : unknown ) => void ;
540+ onmessageerror : ( message : MessageEvent ) => void ;
540541 constructor ( name : string ) ;
541542 /**
542543 * Closes the `BroadcastChannel` connection.
Original file line number Diff line number Diff line change @@ -128,8 +128,12 @@ import { createContext } from "node:vm";
128128 bc . close ( ) ;
129129 bc . ref ( ) ;
130130 bc . unref ( ) ;
131- bc . onmessage = ( msg : unknown ) => { } ;
132- bc . onmessageerror = ( msg : unknown ) => { } ;
131+ bc . onmessage = ( msg ) => {
132+ msg ; // $ExpectType MessageEvent<any>
133+ } ;
134+ bc . onmessageerror = ( msg ) => {
135+ msg ; // $ExpectType MessageEvent<any>
136+ } ;
133137
134138 // Test global alias
135139 const bc2 = new BroadcastChannel ( "test" ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ declare module "worker_threads" {
5959 import { Readable , Writable } from "node:stream" ;
6060 import { ReadableStream , TransformStream , WritableStream } from "node:stream/web" ;
6161 import { URL } from "node:url" ;
62+ import { MessageEvent } from "undici-types" ;
6263 const isMainThread : boolean ;
6364 const parentPort : null | MessagePort ;
6465 const resourceLimits : ResourceLimits ;
@@ -544,18 +545,18 @@ declare module "worker_threads" {
544545 * ```
545546 * @since v15.4.0
546547 */
547- class BroadcastChannel {
548+ class BroadcastChannel extends EventTarget {
548549 readonly name : string ;
549550 /**
550551 * Invoked with a single \`MessageEvent\` argument when a message is received.
551552 * @since v15.4.0
552553 */
553- onmessage : ( message : unknown ) => void ;
554+ onmessage : ( message : MessageEvent ) => void ;
554555 /**
555556 * Invoked with a received message cannot be deserialized.
556557 * @since v15.4.0
557558 */
558- onmessageerror : ( message : unknown ) => void ;
559+ onmessageerror : ( message : MessageEvent ) => void ;
559560 constructor ( name : string ) ;
560561 /**
561562 * Closes the `BroadcastChannel` connection.
Original file line number Diff line number Diff line change @@ -144,8 +144,12 @@ import { createContext } from "node:vm";
144144 bc . close ( ) ;
145145 bc . ref ( ) ;
146146 bc . unref ( ) ;
147- bc . onmessage = ( msg : unknown ) => { } ;
148- bc . onmessageerror = ( msg : unknown ) => { } ;
147+ bc . onmessage = ( msg ) => {
148+ msg ; // $ExpectType MessageEvent<any>
149+ } ;
150+ bc . onmessageerror = ( msg ) => {
151+ msg ; // $ExpectType MessageEvent<any>
152+ } ;
149153
150154 // Test global alias
151155 const bc2 = new BroadcastChannel ( "test" ) ;
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ declare module "worker_threads" {
6363 import { ReadableStream , TransformStream , WritableStream } from "node:stream/web" ;
6464 import { URL } from "node:url" ;
6565 import { HeapInfo } from "node:v8" ;
66+ import { MessageEvent } from "undici-types" ;
6667 const isInternalThread : boolean ;
6768 const isMainThread : boolean ;
6869 const parentPort : null | MessagePort ;
@@ -573,18 +574,18 @@ declare module "worker_threads" {
573574 * ```
574575 * @since v15.4.0
575576 */
576- class BroadcastChannel {
577+ class BroadcastChannel extends EventTarget {
577578 readonly name : string ;
578579 /**
579580 * Invoked with a single \`MessageEvent\` argument when a message is received.
580581 * @since v15.4.0
581582 */
582- onmessage : ( message : unknown ) => void ;
583+ onmessage : ( message : MessageEvent ) => void ;
583584 /**
584585 * Invoked with a received message cannot be deserialized.
585586 * @since v15.4.0
586587 */
587- onmessageerror : ( message : unknown ) => void ;
588+ onmessageerror : ( message : MessageEvent ) => void ;
588589 constructor ( name : string ) ;
589590 /**
590591 * Closes the `BroadcastChannel` connection.
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ declare module "worker_threads" {
6363 import { ReadableStream , TransformStream , WritableStream } from "node:stream/web" ;
6464 import { URL } from "node:url" ;
6565 import { HeapInfo } from "node:v8" ;
66+ import { MessageEvent } from "undici-types" ;
6667 const isInternalThread : boolean ;
6768 const isMainThread : boolean ;
6869 const parentPort : null | MessagePort ;
@@ -574,18 +575,18 @@ declare module "worker_threads" {
574575 * ```
575576 * @since v15.4.0
576577 */
577- class BroadcastChannel {
578+ class BroadcastChannel extends EventTarget {
578579 readonly name : string ;
579580 /**
580581 * Invoked with a single \`MessageEvent\` argument when a message is received.
581582 * @since v15.4.0
582583 */
583- onmessage : ( message : unknown ) => void ;
584+ onmessage : ( message : MessageEvent ) => void ;
584585 /**
585586 * Invoked with a received message cannot be deserialized.
586587 * @since v15.4.0
587588 */
588- onmessageerror : ( message : unknown ) => void ;
589+ onmessageerror : ( message : MessageEvent ) => void ;
589590 constructor ( name : string ) ;
590591 /**
591592 * Closes the `BroadcastChannel` connection.
You can’t perform that action at this time.
0 commit comments