Cannot use schema validate from ajv
kamontat opened this issue · 2 comments
kamontat commented
Problem
The generated code on schema section is below
const ajv_1 = require("ajv");
if (options.schema) {
if (typeof options.schema !== 'object') {
throw new TypeError('The `schema` option must be an object.');
}
const ajv = new ajv_1.default({ // problem from here
allErrors: true,
useDefaults: true
});
const schema = {
type: 'object',
properties: options.schema
};
__classPrivateFieldSet(this, _validator, ajv.compile(schema));
for (const [key, value] of Object.entries(options.schema)) {
if (value === null || value === void 0 ? void 0 : value.default) {
__classPrivateFieldGet(this, _defaultValues)[key] = value.default;
}
}
}
it add .default
after require ajv from node_modules but when ajv export, it didn't use any default key as screenshot below
So now it throw TypeError: ajv_1.default is not a constructor
error.
P.S I use this via electron-store
library
Version
conf: version 9.0.0
os: Macos version 11.1 (20C69)
Big Sur
node: v15.5.1
yarn: v1.22.10
sindresorhus commented
I just npm install ajv
and it does have a .default
property. You are looking at the lib
folder, while you need to look at dist
.
kamontat commented