refactor: cleanup some type casting
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 10 Mar 2024 16:25:42 +0000 (17:25 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 10 Mar 2024 16:25:42 +0000 (17:25 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ui-server/ui-services/AbstractUIService.ts
src/utils/Utils.ts

index 204b5431629e82c753bc57d52fe885753344ebfb..6aed70a1b555cfcf5718cc153d02edc3e25da894 100644 (file)
@@ -4,6 +4,7 @@ import {
   type BroadcastChannelRequestPayload,
   type ChargingStationOptions,
   ConfigurationSection,
+  type JsonObject,
   type JsonType,
   ProcedureName,
   type ProtocolRequest,
@@ -326,7 +327,7 @@ export abstract class AbstractUIService {
     try {
       return {
         status: ResponseStatus.SUCCESS,
-        state: Bootstrap.getInstance().getState()
+        state: Bootstrap.getInstance().getState() as unknown as JsonObject
       } satisfies ResponsePayload
     } catch (error) {
       return {
index 32bac44d3a9123d9d250cbf5d839d7d32e68ee8e..4c4c20f234ff02faf4f79974db7913858b0c0dd7 100644 (file)
@@ -316,13 +316,13 @@ export const JSONStringify = <
       if (value instanceof Map) {
         switch (mapFormat) {
           case MapStringifyFormat.object:
-            return { ...Object.fromEntries<Map<string, T>>(value.entries()) }
+            return { ...Object.fromEntries<Map<string, Record<string, unknown>>>(value.entries()) }
           case MapStringifyFormat.array:
           default:
             return [...value]
         }
       } else if (value instanceof Set) {
-        return [...value] as unknown[]
+        return [...value] as JsonType[]
       }
       return value
     },