ajv-formats
ajv-formats copied to clipboard
Type error running with [email protected]
Hey, I'm not sure if this issue belongs here or to ajv
package.
I get a ts error Argument of type 'import("node_modules/ajv/dist/ajv").default' is not assignable to parameter of type 'import("node_modules/ajv-formats/node_modules/ajv/dist/core").default'.
when passing ajv
object to ajv-formats
:
import Ajv from "ajv";
import addAjvFormats from "ajv-formats";
const ajv = new Ajv();
addAjvFormats(ajv);
This is because ajv
package holds 2 different definitions for Ajv
class:
https://github.com/ajv-validator/ajv/blob/master/lib/core.ts#L275
https://github.com/ajv-validator/ajv/blob/master/lib/ajv.ts#L11
The first one is used in ajv
default export type definition and the second one - in ajv-formats
type definitions. Could you plz fix the typings, or better to address this issue to ajv
package as they hold 2 divergent definitions?
Just make sure that in your lockfile you don't have multiple versions of ajv & you should be good.