Throw an error for a declare class field that have an initializer (#12093)

This commit is contained in:
Sosuke Suzuki 2020-09-22 22:23:58 +09:00 committed by GitHub
parent 3628c52867
commit cb4e436018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -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);
}

View File

@ -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}},