You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
content/endpoint-manager.ts:3:21 - error TS2345: Argument of type '{ strict: boolean; validateSchema: boolean; logger: boolean; }' is not assignable to parameter of type 'Options'.
Type '{ strict: boolean; validateSchema: boolean; logger: boolean; }' is not assignable to type 'CurrentOptions'.
Types of property 'logger' are incompatible.
Type 'boolean' is not assignable to type 'false | Logger'.
3 const ajv = new Ajv(options);
Describe the change that should be made to address the issue?
Accept false as setting for logger as described in the documentation: https://ajv.js.org/options.html#logger
Are you going to resolve the issue?
Sorry, I do not know how.
The text was updated successfully, but these errors were encountered:
Hi @jmozmoz, this is a limitation of TypeScript and not related to AJV.
The reason it happens is AJV requires this type be false | Logger. When you declare an object with a property of false though, TypeScript interprets that as boolean. I'm not sure why exactly, maybe the issues is that objects are mutable so TS can't be sure it will always be false? In any case it can be fixed by adding as const to your options object or as false to the false value.
const options = {strict: false, validateSchema: false, logger: false} as const; or logger: false as false
As this is a TS peculiarity I will close this ticket but thanks for sharing.
What version of Ajv are you using? Does the issue happen if you use the latest version?
ajv@8.12.0
Your typescript code
Typescript compiler error messages
The following code compiles without error:
This one also:
Describe the change that should be made to address the issue?
Accept
false
as setting for logger as described in the documentation:https://ajv.js.org/options.html#logger
Are you going to resolve the issue?
Sorry, I do not know how.
The text was updated successfully, but these errors were encountered: