-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Port parts of Structured Errors to TS + Add two more errors #20597
Conversation
111b6de
to
2bcf5a8
Compare
|
||
interface IConstructError { | ||
details: { | ||
id?: keyof typeof errorMap |
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 now allows for auto completion of all error IDs 👍
column: number | ||
} | ||
|
||
interface IStructuredError { |
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 schema is more or less copied from the joi
schema
@@ -0,0 +1,20 @@ | |||
import errorParser from "../error-parser" | |||
|
|||
describe(`query-error-parser`, () => { |
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.
I added the describe block so that Webstorm can run it 😬
...cb(matched), | ||
...{ location }, |
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.
TS was complaining about ...(location && { location })
so I dropped the check. It'll return undefined
now. Which is fine as we check for truthy values on that further down the line.
return { | ||
id: `11330`, | ||
context: { message: match[0], arg: match[1] }, | ||
context: { sourceMessage: match[0], arg: match[1] }, |
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.
message
was inconsistent here (The IMatch interface unconvered that) so it was changed to sourceMessage
- also in error-map
console.log.mockClear() | ||
process.exit.mockClear() | ||
;(console.log as jest.Mock).mockClear() | ||
;((process.exit as unknown) as jest.Mock).mockClear() |
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.
lol what a goofy syntax
Aside from rebasing, is there anything stopping this being merged? |
nope. The PR #20749 should address Michal's comment: #20749 (comment) so it's not blocking for this PR |
Description
More improvements to our structured errors and also porting some parts over to TS. What has been done:
joi
message
tosourceMessage
on 11321message
tosourceMessage
How to test / Screenshots
Before:
After:
Before:
After:
Documentation
So far no docs changes needed.
Related Issues
Part 2 of #20120
Appendix
My list of ideas of what to fix:
gatsby new
#20571 (Really weird CLI behavior, need to investigate more)