diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index ecf1255af9..c0e4b8a0c5 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -2281,7 +2281,7 @@ export default (superClass: Class): Class => 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); } diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json b/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json index 8876797835..a9dd381301 100644 --- a/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json @@ -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}},