Skip to content

Can't import ValidationError type #1926

Closed
@reisandbeans

Description

@reisandbeans

What version of Ajv are you using? Does the issue happen if you use the latest version? 8.10.0

Your typescript code

Both snippets below fail:

import Ajv, {
    AnySchema,
    AsyncValidateFunction,
    ErrorObject,
    JSONSchemaType,
    KeywordDefinition,
    Options,
    ValidateFunction,
} from 'ajv';

const error: Ajv.ValidationError = ... // 'Ajv' only refers to a type, but is being used as a namespace here
import Ajv, {
    AnySchema,
    AsyncValidateFunction,
    ErrorObject,
    JSONSchemaType,
    KeywordDefinition,
    Options,
    ValidateFunction,
    ValidationError,   // <----------- module ajv has no exported member ValidationError
} from 'ajv';

Typescript compiler error messages

see inline above. As additional context, here are my Typescript compiler options:

{
    "compilerOptions": {
        "declaration": true,
        "emitDecoratorMetadata": true,
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "forceConsistentCasingInFileNames": true,
        "importHelpers": true,
        "lib": [
            "es2018"
        ],
        "module": "commonjs",
        "moduleResolution": "node",
        "noEmitOnError": true,
        "noImplicitAny": true,
        "removeComments": true,
        "skipLibCheck": true,
        "sourceMap": true,
        "strict": true,
        "target": "es2017"
    }
}

Describe the change that should be made to address the issue? Export ValidationError at the top level along with other ajv types

Are you going to resolve the issue? If this is confirmed as an issue sure, I can try. But I just wanted to validate first that it's not me doing something wrong.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions