Skip to content

Commit 4f27112

Browse files
authored
fix type compatibility with node 10+ (#392)
1 parent 2e443c3 commit 4f27112

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/types/master.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ export type TransferList = Transferable[]
7676
/** Worker instance. Either a web worker or a node.js Worker provided by `worker_threads` or `tiny-worker`. */
7777
export interface Worker extends EventTarget {
7878
postMessage(value: any, transferList?: TransferList): void
79-
terminate(callback?: (error?: Error, exitCode?: number) => void): void
79+
/** In nodejs 10+ return type is Promise while with tiny-worker and in browser return type is void */
80+
terminate(callback?: (error?: Error, exitCode?: number) => void): void | Promise<number>
8081
}
81-
8282
export interface ThreadsWorkerOptions extends WorkerOptions {
8383
/** Prefix for the path passed to the Worker constructor. Web worker only. */
8484
_baseURL?: string
@@ -102,7 +102,7 @@ export interface ThreadsWorkerOptions extends WorkerOptions {
102102
export declare class WorkerImplementation extends EventTarget implements Worker {
103103
constructor(path: string, options?: ThreadsWorkerOptions)
104104
public postMessage(value: any, transferList?: TransferList): void
105-
public terminate(): void
105+
public terminate(): void | Promise<number>
106106
}
107107

108108
/** Class to spawn workers from a blob or source string. */

0 commit comments

Comments
 (0)