Prepare code for strict type checking
[e-mobility-charging-stations-simulator.git] / src / charging-station / StationWorker.ts
index 20fb27ca04ae47a533f7109525f07a8e7bba1768..5977b8e0eae322cdb32b1493d6e4719faf4357ca 100644 (file)
@@ -19,10 +19,10 @@ if (Utils.workerPoolInUse()) {
 }
 
 /**
- *
+ * Listen messages send by the main thread
  */
 function addMessageListener(): void {
-  parentPort.on('message', (message) => {
+  parentPort?.on('message', (message) => {
     if (message.id === WorkerEvents.START_WORKER_ELEMENT) {
       startChargingStation(message.workerData);
     }
@@ -30,7 +30,9 @@ function addMessageListener(): void {
 }
 
 /**
- * @param data
+ * Create and start a charging station instance
+ *
+ * @param {StationWorkerData} data workerData
  */
 function startChargingStation(data: StationWorkerData): void {
   const station = new ChargingStation(data.index, data.templateFile);