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<void>;
this.validateResponsePayload = this.validateResponsePayload.bind(this) as <T extends JsonType>(
chargingStation: ChargingStation,
validate.errors,
);
throw new OCPPError(
- OCPPServiceUtils.ajvErrorsToErrorType(validate.errors),
+ OCPPServiceUtils.ajvErrorsToErrorType(validate.errors!),
'Response PDU is invalid',
commandName,
JSON.stringify(validate.errors, null, 2),
/* This is intentional */
}
- public abstract responseHandler(
+ public abstract responseHandler<ReqType extends JsonType, ResType extends JsonType>(
chargingStation: ChargingStation,
commandName: RequestCommand,
- payload: JsonType,
- requestPayload: JsonType,
+ payload: ResType,
+ requestPayload: ReqType,
): Promise<void>;
}