Skip to content

TypeScript issue in ValidationError instance #90

@weiyuan1993

Description

@weiyuan1993

I found out that ValidationError is extended from the Error instance.
If you do this below in TypeScript:

const validationError = new ValidationError({
  params: [{
    dataPath: '.id',
    keyword: 'maxLength',
    message: 'should NOT be longer than 2 characters',
    params: { limit: 2 },
    schemaPath: '#/properties/id/maxLength'
  }]
})

It will throw a ts compile error because the argument type should be a string.
Screen Shot 2021-08-11 at 2 10 07 PM

To fix this problem, I just add // @ts-ignore before new ValidationError.

Any better support for this?

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