Falsy/truthy test fixes
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPRequestService.ts
index fc4410f8658653b16e5305b8251441fe0577ae55..6a7729950de33b2532fb1b8c0153dc170280a957 100644 (file)
@@ -68,7 +68,7 @@ export default abstract class OCPPRequestService {
     messageId: string,
     messagePayload: JsonType,
     commandName: IncomingRequestCommand
-  ): Promise<ResponseType | undefined> {
+  ): Promise<ResponseType> {
     try {
       // Send response message
       return await this.internalSendMessage(
@@ -232,7 +232,7 @@ export default abstract class OCPPRequestService {
       return Utils.promiseWithTimeout(
         new Promise((resolve, reject) => {
           if (chargingStation.getEnableStatistics() === true) {
-            chargingStation.performanceStatistics.addRequestStatistic(commandName, messageType);
+            chargingStation.performanceStatistics?.addRequestStatistic(commandName, messageType);
           }
           const messageToSend = this.buildMessageToSend(
             chargingStation,
@@ -306,7 +306,7 @@ export default abstract class OCPPRequestService {
            */
           function responseCallback(payload: JsonType, requestPayload: JsonType): void {
             if (chargingStation.getEnableStatistics() === true) {
-              chargingStation.performanceStatistics.addRequestStatistic(
+              chargingStation.performanceStatistics?.addRequestStatistic(
                 commandName,
                 MessageType.CALL_RESULT_MESSAGE
               );
@@ -338,7 +338,7 @@ export default abstract class OCPPRequestService {
            */
           function errorCallback(error: OCPPError, requestStatistic = true): void {
             if (requestStatistic === true && chargingStation.getEnableStatistics() === true) {
-              chargingStation.performanceStatistics.addRequestStatistic(
+              chargingStation.performanceStatistics?.addRequestStatistic(
                 commandName,
                 MessageType.CALL_ERROR_MESSAGE
               );