ForbesLindesay/typescript-json-validator

Invalid validator file generated

Opened this issue · 0 comments

I'm seeing an issue that was supposedly fixed here #17
This issue is still occurring to me in version 2.4.2.

This is a part of the generated validator.

/* tslint:disable */
// generated by typescript-json-validator
import { inspect } from 'util';
import Ajv = require('ajv');
export const ajv = new Ajv({
    allErrors: true,
    coerceTypes: false,
    format: 'fast',
    nullable: true,
    unicode: true,
    uniqueItems: true,
    useDefaults: true,
});

ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));

In the browser I'm getting

blueprint.model.validator.ts:6 Uncaught ReferenceError: Ajv is not defined

Changing import Ajv = require('ajv'); to const Ajv = require('ajv'); makes it work.

Also, interfaces are imported using default import even though the interface file has no default exports.