Skip to content

TS2351: This expression is not constructable. #49

@Jurajzovinec

Description

@Jurajzovinec

After my update of package-log.json file this compilation error is thrown.

TSError: ⨯ Unable to compile TypeScript:
src/components/campaigns/controllers/validators/validate-agents.ts:6:24 - error TS2351: This expression is not constructable.
  Type 'typeof import("/Users/jurajzovinec/Documents/MY CLOUDTALK PROJECTS/campaigns/node_modules/ajv/dist/ajv")' has no construct signatures.

validator function

import { inspect } from 'util'
import Ajv = require('ajv')
import { Agents } from '../shared/types'
export const ajv = new Ajv({              // Ajv is underscored
	allErrors: true,
	coerceTypes: false,
	format: 'fast',
	nullable: true,
	unicode: true,
	uniqueItems: true,
	useDefaults: true,
})

Ajv reference

import type { AnySchemaObject } from "./types";
import AjvCore from "./core";
declare class Ajv extends AjvCore {
    _addVocabularies(): void;
    _addDefaultMetaSchema(): void;
    defaultMeta(): string | AnySchemaObject | undefined;
}
export default Ajv;
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, SchemaValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core";
export { SchemaCxt, SchemaObjCxt } from "./compile";
export { KeywordCxt } from "./compile/validate";
export { DefinedError } from "./vocabularies/errors";
export { JSONType } from "./compile/rules";
export { JSONSchemaType } from "./types/json-schema";
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";

Also deprecation warning thrown at npm install may be helpful
npm WARN deprecated @types/[email protected]: This is a stub types definition for ajv (https://github.com/epoberezkin/ajv). ajv provides its own type definitions, so you don't need @types/ajv installed!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions