-
-
Notifications
You must be signed in to change notification settings - Fork 883
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
More user friendly ErrorObject TypeScript type #1090
Comments
@epoberezkin any thoughts? |
@torifat Sorry for ignoring it... Looking at it now - it is probably the right approach. Now that it is re-written in typescript - probably error type should be defined by each keyword locally (although given that it is returned via generated code it won't be connected to the actual code, just visually) |
The only problem I see with this approach is that ErrorObject should be an open union, to allow users extending it when they define custom keywords without modifying Ajv code base - trying to figure out how to do it in typescript... @torifat any suggestion would be fantastic. |
in v7-alpha |
What problem do you want to solve?
In its current state
ErrorObject
is not very user friendly in certain scenarios. For example:It would be really useful if we could get
EnumParams
here, instead ofErrorParameters
. It's possible to use type-guards to achieve something similar but the code gets a bit messier.What do you think is the correct solution to problem?
IMO it can be improved by using discriminated unions. If we do something like:
Then we will get
EnumParams
inside theenum
case.Will you be able to implement it?
Yes
The text was updated successfully, but these errors were encountered: