diff --git a/lib/standalone/index.ts b/lib/standalone/index.ts index 5f1fa2066..eaf2dd238 100644 --- a/lib/standalone/index.ts +++ b/lib/standalone/index.ts @@ -11,7 +11,7 @@ export default function standaloneCode( if (!ajv.opts.code.source) { throw new Error("moduleCode: ajv instance must have code.source option") } - const _n = ajv.scope.opts._n + const {_n} = ajv.scope.opts return typeof refsOrFunc == "function" ? funcExportCode(refsOrFunc.source) : refsOrFunc !== undefined diff --git a/spec/after_test.ts b/spec/after_test.ts index 64515d861..91a9fbca0 100644 --- a/spec/after_test.ts +++ b/spec/after_test.ts @@ -1,23 +1,31 @@ +import type Ajv from ".." +import type {AnySchema, ErrorObject} from ".." import chai from "./chai" const should = chai.should() -module.exports = { - error: afterError, - each: afterEach, +interface TestResult { + validator: Ajv + schema: AnySchema + data: unknown + valid: boolean + expected: boolean + errors: ErrorObject[] | null + passed: boolean // true if valid == expected } -export function afterError(res): void { +export function afterError(res: TestResult): void { console.log("ajv options:", res.validator.opts) } -export function afterEach(res): void { +export function afterEach(res: TestResult): void { // console.log(res.errors); res.valid.should.be.a("boolean") if (res.valid === true) { should.equal(res.errors, null) } else { - res.errors.should.be.an("array") - for (const err of res.errors) { + const errs = res.errors as ErrorObject[] + errs.should.be.an("array") + for (const err of errs) { err.should.be.an("object") } }