build: properly workaround Ajv TS type definitions bug
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPResponseService.ts
index e386e432a88ac334f7434ec6ea33f64c6a28c011..a80bc2b730564d24110fbbc5026688ddf0e46df1 100644 (file)
@@ -1,5 +1,5 @@
-import Ajv, { type JSONSchemaType, type ValidateFunction } from 'ajv';
-import ajvFormats from 'ajv-formats';
+import _Ajv, { type JSONSchemaType, type ValidateFunction } from 'ajv';
+import _ajvFormats from 'ajv-formats';
 
 import { OCPPServiceUtils } from './OCPPServiceUtils.js';
 import type { ChargingStation } from '../../charging-station/index.js';
@@ -11,6 +11,9 @@ import type {
   RequestCommand,
 } from '../../types/index.js';
 import { logger } from '../../utils/index.js';
+type Ajv = _Ajv.default;
+const Ajv = _Ajv.default;
+const ajvFormats = _ajvFormats.default;
 
 const moduleName = 'OCPPResponseService';
 
@@ -33,7 +36,6 @@ export abstract class OCPPResponseService {
 
   protected constructor(version: OCPPVersion) {
     this.version = version;
-    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
     this.ajv = new Ajv({
       keywords: ['javaType'],
       multipleOfPrecision: 2,
@@ -102,7 +104,6 @@ export abstract class OCPPResponseService {
     schema: JSONSchemaType<T>,
   ) {
     if (this.jsonRequestValidateFunctions.has(commandName) === false) {
-      // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
       this.jsonRequestValidateFunctions.set(commandName, this.ajv.compile<T>(schema).bind(this));
     }
     return this.jsonRequestValidateFunctions.get(commandName)!;