-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Make ParseError Much Simpler now that we can use TypeScript #14796
Conversation
…ow that we can use TypeScript. Reviewed by @tolmasky.
Reviewed by @tolmasky.
Reviewed by @tolmasky.
… factoring it out. Reviewed by @tolmasky.
Reviewed by @tolmasky.
…ay, and we may want to change this back to string when we allow custom sytnax plugins (or "SyntaxPlugin | string" just to convey this a bit better, even though that would be the same). Reviewed by @tolmasky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
Reviewed by @tolmasky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is great and it looks so much better now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks great to me.
As originally promised in the TypeSafe Errors PR, this PR dramatically simplifies all the
ParseError
machinery now that we are on TypeScript (woooo!!!). From a usability perspective, it is now much easier to define error templates, no longer requiring the use of the weird_()
flow-workaround-function. So, before you'd have to do something like this:And now you instead do this:
In other words, we've kept the simplicity of the old object reason-code to message mapping, but with real types. This was of course the original goal, but many flow bugs prevented us from doing this as cleanly, so we needed these weird "carrier" functions (like
toParseErrorCredentials
) to shuttle the types around. TypeScript is much better at tracking the types everywhere and so we no longer need them and can so we can just use normal objects.Aside from that, there are just a few random fixes to get rid of
ts-expect-error
s, etc., and updating comments to reflect the new code.