Skip to content

Commit

Permalink
Throw an error for a declare class field that have an initializer (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Sep 22, 2020
1 parent 3628c52 commit cb4e436
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-parser/src/plugins/typescript/index.js
Expand Up @@ -2281,7 +2281,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
parseClassProperty(node: N.ClassProperty): N.ClassProperty {
this.parseClassPropertyAnnotation(node);

if (node.declare && this.match(tt.equal)) {
if (node.declare && this.match(tt.eq)) {
this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);
}

Expand Down
@@ -1,6 +1,9 @@
{
"type": "File",
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: 'declare' class fields cannot have an initializer (2:22)"
],
"program": {
"type": "Program",
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
Expand Down

0 comments on commit cb4e436

Please sign in to comment.