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
Improve syntax error for class fields in ambient context #12108
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/28854/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 05ad22c:
|
@@ -2289,7 +2289,7 @@ export default (superClass: Class<Parser>): Class<Parser> => | |||
parseClassProperty(node: N.ClassProperty): N.ClassProperty { | |||
this.parseClassPropertyAnnotation(node); | |||
|
|||
if (node.declare && this.match(tt.eq)) { | |||
if ((node.declare || this.state.isDeclareContext) && this.match(tt.eq)) { |
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.
Does node.declare
imply this.state.isDeclareContext
? If so we can remove node.declare
checks.
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.
No, this.state.isDeclareContext
is not for class member with declare
modifier.
EDIT:
I've fixed to use this.isDeclareContext
for class member with declare
modifier at 05ad22c.
* Install babel/parser 7.12 * Add tests for babel/babel#12161 * Add test for babel/babel#12076 * Add test for babel/babel#12085 * Add test for babel/babel#12108 * Add test for babel/babel#12120 * Add test for babel/babel#12054 * Add test for babel/babel#12061 * Add test babel/babel#12093 * Add test for babel/babel#12065 * Add test for babel/babel#12111 * Add test for babel/babel#12072 * Switch syntax-module-attributes to syntax-import-assertion * Support "String import/export specifier" * Remove tests for module-attributes * Add changelog * Update to 7.12.3 * Fix by linter * Fix by spellchecker * Add tests for module attributes to errors * Add error test for module string name with import * Remove TSTypeCastExpression * Add tests for funny import-assertions * Update snapshots| * Add more tests
'declare' class fields cannot have an initializer
Initializers are not allowed in ambient contexts.