Throw an error for a declare class field that have an initializer (#12093)
This commit is contained in:
parent
3628c52867
commit
cb4e436018
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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}},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user