Hello!
I've just attempted my first Deno project and I've run into puzzling issue - I have here a class that takes Ajv and ajv-formats to implement JSON Schema validation and everythings file before I try to run test cases. This code:
import formatsPlugin from 'https://cdn.skypack.dev/[email protected]?dts';
import Ajv from 'https://cdn.skypack.dev/[email protected]?dts';
export class Validator {
private validator: Ajv;
constructor(private schema: any) {
this.validator = new Ajv();
console.log(this.validator)
formatsPlugin(this.validator);
}
get errors() {
return this.validator.errors;
}
validate(data: any): boolean {
const isValid = this.validator.validate(this.schema, data);
return isValid;
}
}
So the problem is that if I try to create an instance of Validator within same file and then execute deno run it works file, but as soon as I'm add some describe/it/asserts to test very same functionality I get an error.
error: TS2345 [ERROR]: Argument of type 'import("https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=types/dist/ajv.d.ts").default' is not assignable to parameter of type ...
Like, runtime and test environments do something different. Which looks strange to me.
Thanks in advance!