ajv-formats icon indicating copy to clipboard operation
ajv-formats copied to clipboard

Type error running with [email protected]

Open Geloosa opened this issue 2 years ago • 1 comments

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?

Geloosa avatar Nov 22 '22 10:11 Geloosa

Just make sure that in your lockfile you don't have multiple versions of ajv & you should be good.

roodie-ree avatar Nov 25 '22 13:11 roodie-ree