From: Jérôme Benoit Date: Fri, 22 Nov 2024 12:54:23 +0000 (+0100) Subject: fix: ensure undefined is handled at computing power limitation X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=55a17ee03b588b4cd5b14276b1f103bcdd3ec0a4;p=e-mobility-charging-stations-simulator.git fix: ensure undefined is handled at computing power limitation closes #1223 Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 45a2f94e..ed7449a9 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -419,19 +419,15 @@ export class ChargingStation extends EventEmitter { const connectorChargingProfilesLimit = getConnectorChargingProfilesLimit(this, connectorId) return min( Number.isNaN(connectorMaximumPower) ? Number.POSITIVE_INFINITY : connectorMaximumPower, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - Number.isNaN(connectorAmperageLimitationLimit!) + connectorAmperageLimitationLimit == null || Number.isNaN(connectorAmperageLimitationLimit) ? Number.POSITIVE_INFINITY - : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connectorAmperageLimitationLimit!, + : connectorAmperageLimitationLimit, Number.isNaN(chargingStationChargingProfilesLimit) ? Number.POSITIVE_INFINITY : chargingStationChargingProfilesLimit, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - Number.isNaN(connectorChargingProfilesLimit!) + connectorChargingProfilesLimit == null || Number.isNaN(connectorChargingProfilesLimit) ? Number.POSITIVE_INFINITY - : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connectorChargingProfilesLimit! + : connectorChargingProfilesLimit ) } diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 5fcc4093..d34749e4 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -29,7 +29,7 @@ export const convertToInt = (value: unknown): number => { if (typeof value === 'string') { changedValue = Number.parseInt(value) } - if (isNaN(changedValue)) { + if (Number.isNaN(changedValue)) { // eslint-disable-next-line @typescript-eslint/no-base-to-string throw new Error(`Cannot convert to integer: '${value.toString()}'`) }