refactor: cleanup unneeded type casting
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16IncomingRequestService.ts
index 8f1a4593d3a02476b819a25a44c4f8ed0ad83a73..f934d418e6161600982b53d0ec7fb2a034682a6e 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
 
 import { createWriteStream, readdirSync } from 'node:fs'
 import { dirname, join, resolve } from 'node:path'
@@ -332,11 +332,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
         )
       ]
     ])
-    this.validatePayload = this.validatePayload.bind(this) as (
-      chargingStation: ChargingStation,
-      commandName: OCPP16IncomingRequestCommand,
-      commandPayload: JsonType
-    ) => boolean
+    this.validatePayload = this.validatePayload.bind(this)
   }
 
   public async incomingRequestHandler<ReqType extends JsonType, ResType extends JsonType>(
@@ -726,10 +722,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
             chargingProfile.chargingProfileId
           } startSchedule property is not a Date instance. Trying to convert it to a Date instance`
         )
-        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
         chargingProfile.chargingSchedule.startSchedule = convertToDate(
           chargingProfile.chargingSchedule.startSchedule
-        )!
+        )
       }
       if (chargingProfile.chargingSchedule.duration == null) {
         logger.debug(
@@ -740,7 +735,8 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
         // OCPP specifies that if duration is not defined, it should be infinite
         chargingProfile.chargingSchedule.duration = differenceInSeconds(
           maxTime,
-          chargingProfile.chargingSchedule.startSchedule
+          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+          chargingProfile.chargingSchedule.startSchedule!
         )
       }
       if (