vacekj/express-json-validator-middleware

TypeScript issue in ValidationError instance

Opened this issue · 0 comments

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?