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

New: Add property decorators to AST (fixes #71) #72

Merged
merged 1 commit into from
Aug 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/ast-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TOKEN_TO_TEXT[SyntaxKind.InKeyword] = "in";
* @returns {boolean} is valid ESTree class member
*/
function isESTreeClassMember(node) {
return node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.SemicolonClassElement;
return node.kind !== SyntaxKind.SemicolonClassElement;
}

/**
Expand Down Expand Up @@ -946,6 +946,19 @@ module.exports = function(ast, extra) {
}
break;

case SyntaxKind.PropertyDeclaration:
assign(result, {
type: "ClassProperty",
key: convertChild(node.name),
value: convertChild(node.initializer),
computed: (node.name.kind === SyntaxKind.ComputedPropertyName),
static: Boolean(node.flags & ts.NodeFlags.Static),
decorators: (node.decorators) ? node.decorators.map(function(d) {
return convertChild(d.expression);
}) : []
});
break;

case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MethodDeclaration:
Expand Down
Loading