Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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: wycats/javascript-decorators@e240cbc * Update flow whitelist
- Loading branch information
1 parent
ca67637
commit 8bf9714
Showing
4 changed files
with
180 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...es/babel-parser/test/fixtures/experimental/decorators/method-generator-decorator/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Foo { | ||
@deco | ||
*generatorMethod() {} | ||
} |
175 changes: 175 additions & 0 deletions
175
...babel-parser/test/fixtures/experimental/decorators/method-generator-decorator/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters