[legacy decorators] Allow decorating generator methods (#9912)
* [legacy decorators] Allow decorating generator methods
The old proposal used LeftHandSideExpression (instead of
AssignmentExpression) to satisfy this usecase:
e240cbc91a
* Update flow whitelist
This commit is contained in:
parent
ca67637da4
commit
8bf9714d69
@ -390,7 +390,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
node.expression = this.parseMaybeDecoratorArguments(expr);
|
||||
this.state.decoratorStack.pop();
|
||||
} else {
|
||||
node.expression = this.parseMaybeAssign();
|
||||
node.expression = this.parseExprSubscripts();
|
||||
}
|
||||
return this.finishNode(node, "Decorator");
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
@deco
|
||||
*generatorMethod() {}
|
||||
}
|
||||
175
packages/babel-parser/test/fixtures/experimental/decorators/method-generator-decorator/output.json
vendored
Normal file
175
packages/babel-parser/test/fixtures/experimental/decorators/method-generator-decorator/output.json
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 10,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 14,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 14,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "deco"
|
||||
},
|
||||
"name": "deco"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"kind": "method",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 23,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "generatorMethod"
|
||||
},
|
||||
"name": "generatorMethod"
|
||||
},
|
||||
"computed": false,
|
||||
"id": null,
|
||||
"generator": true,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 41,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,6 @@ async_generators/migrated_0007.js
|
||||
class_properties/migrated_0021.js
|
||||
class_properties/migrated_0026.js
|
||||
decorators/migrated_0003.js
|
||||
decorators/migrated_0007.js
|
||||
private_class_properties/multiple.js
|
||||
private_class_properties/super.js
|
||||
private_class_properties/getter_and_field.js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user