1
+ import type { MessagePort as NodeMessagePort } from 'worker_threads' ;
2
+
1
3
/**
2
4
* Comlink library protocol extension to use synchronous messaging.
3
5
*
@@ -155,9 +157,7 @@ export function wrapSync<T>(
155
157
156
158
/// Transport ///
157
159
158
- export type IsomorphicMessagePort =
159
- | MessagePort
160
- | import ( 'worker_threads' ) . MessagePort ;
160
+ export type IsomorphicMessagePort = MessagePort | NodeMessagePort ;
161
161
162
162
export class NodeSABSyncReceiveMessageTransport {
163
163
static receiveMessageOnPort : any ;
@@ -246,13 +246,13 @@ export interface EventSource {
246
246
addEventListener (
247
247
type : string ,
248
248
listener : EventListenerOrEventListenerObject ,
249
- options ?: { }
249
+ options ?: object
250
250
) : void ;
251
251
252
252
removeEventListener (
253
253
type : string ,
254
254
listener : EventListenerOrEventListenerObject ,
255
- options ?: { }
255
+ options ?: object
256
256
) : void ;
257
257
}
258
258
@@ -714,7 +714,7 @@ export function expose(
714
714
}
715
715
}
716
716
} )
717
- . catch ( ( error ) => {
717
+ . catch ( ( ) => {
718
718
// Send Serialization Error To Caller
719
719
const [ wireValue , transferables ] = toWireValue ( {
720
720
value : new TypeError ( 'Unserializable return value' ) ,
@@ -774,6 +774,7 @@ function releaseEndpoint(ep: Endpoint) {
774
774
}
775
775
776
776
interface FinalizationRegistry < T > {
777
+ // @ts -ignore
777
778
new ( cb : ( heldValue : T ) => void ) : FinalizationRegistry < T > ;
778
779
register (
779
780
weakItem : object ,
@@ -782,7 +783,7 @@ interface FinalizationRegistry<T> {
782
783
) : void ;
783
784
unregister ( unregisterToken : object ) : void ;
784
785
}
785
- declare var FinalizationRegistry : FinalizationRegistry < Endpoint > ;
786
+ declare const FinalizationRegistry : FinalizationRegistry < Endpoint > ;
786
787
787
788
const proxyCounter = new WeakMap < Endpoint , number > ( ) ;
788
789
const proxyFinalizers =
@@ -915,7 +916,7 @@ export function transfer<T>(obj: T, transfers: Transferable[]): T {
915
916
return obj ;
916
917
}
917
918
918
- export function proxy < T extends { } > ( obj : T ) : T & ProxyMarked {
919
+ export function proxy < T extends object > ( obj : T ) : T & ProxyMarked {
919
920
return Object . assign ( obj , { [ proxyMarker ] : true } ) as any ;
920
921
}
921
922
@@ -996,12 +997,12 @@ export interface NodeEndpoint {
996
997
on (
997
998
type : string ,
998
999
listener : EventListenerOrEventListenerObject ,
999
- options ?: { }
1000
+ options ?: object
1000
1001
) : void ;
1001
1002
off (
1002
1003
type : string ,
1003
1004
listener : EventListenerOrEventListenerObject ,
1004
- options ?: { }
1005
+ options ?: object
1005
1006
) : void ;
1006
1007
start ?: ( ) => void ;
1007
1008
}
0 commit comments