X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=7934500ed3ebd7612cfb05ad58b0c68699396dc1;hb=3fb26594ef01e3f443bcc0bbf81401c6e38fdc01;hp=b15b7cd6ad2a397febed5205014a5a26c4f57cf1;hpb=5edd8ba0f8978cfb3ca9d80f299d9748c6c5970e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index b15b7cd6..7934500e 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -31,11 +31,14 @@ export abstract class OCPPResponseService { multipleOfPrecision: 2, }); ajvFormats(this.ajv); - this.responseHandler = this.responseHandler.bind(this) as ( + this.responseHandler = this.responseHandler.bind(this) as < + ReqType extends JsonType, + ResType extends JsonType, + >( chargingStation: ChargingStation, commandName: RequestCommand, - payload: JsonType, - requestPayload: JsonType, + payload: ResType, + requestPayload: ReqType, ) => Promise; this.validateResponsePayload = this.validateResponsePayload.bind(this) as ( chargingStation: ChargingStation, @@ -70,7 +73,7 @@ export abstract class OCPPResponseService { validate.errors, ); throw new OCPPError( - OCPPServiceUtils.ajvErrorsToErrorType(validate.errors), + OCPPServiceUtils.ajvErrorsToErrorType(validate.errors!), 'Response PDU is invalid', commandName, JSON.stringify(validate.errors, null, 2), @@ -81,10 +84,10 @@ export abstract class OCPPResponseService { /* This is intentional */ } - public abstract responseHandler( + public abstract responseHandler( chargingStation: ChargingStation, commandName: RequestCommand, - payload: JsonType, - requestPayload: JsonType, + payload: ResType, + requestPayload: ReqType, ): Promise; }