Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error using ajv-formats with ajv v8.11.0 #67

Open
tnguye72 opened this issue May 9, 2022 · 1 comment
Open

Type Error using ajv-formats with ajv v8.11.0 #67

tnguye72 opened this issue May 9, 2022 · 1 comment

Comments

@tnguye72
Copy link

tnguye72 commented May 9, 2022

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?

@rygo11
Copy link

rygo11 commented May 30, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants