multipleOfPrecision: 2,
});
ajvFormats(this.ajv);
- this.incomingRequestHandler = this.incomingRequestHandler.bind(this) as (
+ this.incomingRequestHandler = this.incomingRequestHandler.bind(this) as <
+ ReqType extends JsonType,
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ ResType extends JsonType,
+ >(
chargingStation: ChargingStation,
messageId: string,
commandName: IncomingRequestCommand,
- commandPayload: JsonType,
+ commandPayload: ReqType,
) => Promise<void>;
this.validateIncomingRequestPayload = this.validateIncomingRequestPayload.bind(this) as <
T extends JsonType,
validate.errors,
);
throw new OCPPError(
- OCPPServiceUtils.ajvErrorsToErrorType(validate.errors),
+ OCPPServiceUtils.ajvErrorsToErrorType(validate.errors!),
'Incoming request PDU is invalid',
commandName,
JSON.stringify(validate.errors, null, 2),
}
protected handleRequestClearCache(chargingStation: ChargingStation): ClearCacheResponse {
- if (chargingStation.idTagsCache.deleteIdTags(getIdTagsFile(chargingStation.stationInfo))) {
+ if (chargingStation.idTagsCache.deleteIdTags(getIdTagsFile(chargingStation.stationInfo)!)) {
return OCPPConstants.OCPP_RESPONSE_ACCEPTED;
}
return OCPPConstants.OCPP_RESPONSE_REJECTED;
}
- public abstract incomingRequestHandler(
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ public abstract incomingRequestHandler<ReqType extends JsonType, ResType extends JsonType>(
chargingStation: ChargingStation,
messageId: string,
commandName: IncomingRequestCommand,
- commandPayload: JsonType,
+ commandPayload: ReqType,
): Promise<void>;
}