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
Update babel parser #10802
Update babel parser #10802
Conversation
"Unexpected token (4:10) | ||
2 | static #x = 42; | ||
3 | static y; | ||
> 4 | static { |
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 should be fixed by babel/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.
src/language-js/parser-babel.js
Outdated
|
||
return true; | ||
function shouldRethrowRecoveredError(error) { |
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.
Remove this function, use allowedMessageCodes
directly.
"throwExpressions", | ||
"classPrivateMethods", |
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.
Can moduleStringNames
plugin removed?
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.
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/plugins/flow/index.js#L51-L140 | ||
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/plugins/jsx/index.js#L23-L39 | ||
const allowedMessageCodes = new Set([ | ||
"StrictNumericEscape", |
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.
The error codes seem less readable than the message. 😢
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.
Probably these error codes are used by only us now, so we can fix too less readable messages on Babel side.
f06ebc2
to
69d4657
Compare
'interface = "foo";', | ||
"interface + 3;", | ||
"interface();", | ||
"class interface {}", | ||
"interface ? true : false;", | ||
"function interface() {}", | ||
'import interface from "foo";', | ||
"interface.foo;", | ||
"new interface();", | ||
'(interface, "foo");', | ||
"void interface;", | ||
'const interface = "foo";', |
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 change makes the Reserved word check rough...
Description
Error Codes are introduced in babel/parser since Babel 7.14.0. Also almost error messages throw by babel/parser are fixed for consistent.
Checklist
✨Try the playground for this PR✨