ajv-formats
ajv-formats copied to clipboard
Type Error using ajv-formats with ajv v8.11.0
I have a typescript project and am following instructions to add "date-time" as follows:
let ajv = new Ajv({ allErrors: true});
addFormats(ajv, ["date-time"]);
but getting the following error for "ajv", the first argument to addFormats:
Type 'Ajv' is missing the following properties from type 'Ajv': opts, logger, scope, schemas, and 17 more.
My tsconfig is as follows:
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2020",
"noImplicitAny": true,
"preserveConstEnums": true,
"outDir": "./build",
"sourceMap": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "node"
},
"exclude": ["node_modules"],
"include": ["my-project/src/**/*", "docs/**/*.json"]
}
The only way I was able to get it working was by initializing ajv as 'any' type, which doesn't seem ideal. Any ideas as to what could be the issue?
I had the same issue and fixed it by making sure I had the most up to date versions of both dependencies: "ajv": "^8.8", "ajv-formats": "^2.1.1",
I think another package must have installed an older version of ajv.