Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit f6a8e71

Browse files
JamesHenrynzakas
authored andcommitted
New: Add property decorators to AST (fixes #71) (#72)
1 parent 328259f commit f6a8e71

9 files changed

+2168
-1
lines changed

lib/ast-converter.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ TOKEN_TO_TEXT[SyntaxKind.InKeyword] = "in";
102102
* @returns {boolean} is valid ESTree class member
103103
*/
104104
function isESTreeClassMember(node) {
105-
return node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.SemicolonClassElement;
105+
return node.kind !== SyntaxKind.SemicolonClassElement;
106106
}
107107

108108
/**
@@ -946,6 +946,19 @@ module.exports = function(ast, extra) {
946946
}
947947
break;
948948

949+
case SyntaxKind.PropertyDeclaration:
950+
assign(result, {
951+
type: "ClassProperty",
952+
key: convertChild(node.name),
953+
value: convertChild(node.initializer),
954+
computed: (node.name.kind === SyntaxKind.ComputedPropertyName),
955+
static: Boolean(node.flags & ts.NodeFlags.Static),
956+
decorators: (node.decorators) ? node.decorators.map(function(d) {
957+
return convertChild(d.expression);
958+
}) : []
959+
});
960+
break;
961+
949962
case SyntaxKind.GetAccessor:
950963
case SyntaxKind.SetAccessor:
951964
case SyntaxKind.MethodDeclaration:

0 commit comments

Comments
 (0)