Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript issue in ValidationError instance #90

Open
weiyuan1993 opened this issue Aug 11, 2021 · 0 comments
Open

TypeScript issue in ValidationError instance #90

weiyuan1993 opened this issue Aug 11, 2021 · 0 comments

Comments

@weiyuan1993
Copy link

weiyuan1993 commented Aug 11, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant