Fix usage of prepublishOnly (#202)
[poolifier.git] / src / utility-types.ts
index aa4d058cce142ffa5214c8d2ce2965e428309d14..7ea86042ff796660b57410561bd1b57a2b9c8025 100644 (file)
@@ -1,5 +1,9 @@
+import type { Worker } from 'cluster'
+import type { MessagePort } from 'worker_threads'
+import type { KillBehavior } from './worker/worker-options'
+
 /**
- * Make all properties in T non-readonly
+ * Make all properties in T non-readonly.
  */
 export type Draft<T> = { -readonly [P in keyof T]?: T[P] }
 
@@ -24,7 +28,10 @@ export type JSONArray = Array<JSONValue>
 /**
  * Message object that is passed between worker and main worker.
  */
-export interface MessageValue<Data = unknown> {
+export interface MessageValue<
+  Data = unknown,
+  MainWorker extends Worker | MessagePort | unknown = unknown
+> {
   /**
    * Input data that will be passed to the worker.
    */
@@ -36,7 +43,7 @@ export interface MessageValue<Data = unknown> {
   /**
    * Kill code.
    */
-  readonly kill?: number
+  readonly kill?: KillBehavior | 1
   /**
    * Error.
    */
@@ -46,5 +53,5 @@ export interface MessageValue<Data = unknown> {
    *
    * _Only for internal use_
    */
-  readonly parent?: MessagePort
+  readonly parent?: MainWorker
 }