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

Fix: Handle assignment within property destructuring (fixes #332) #336

Merged
merged 1 commit into from
Jul 10, 2017
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
39 changes: 29 additions & 10 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,17 +666,36 @@ module.exports = function convert(config) {
});
break;

case SyntaxKind.ShorthandPropertyAssignment:
Object.assign(result, {
type: AST_NODE_TYPES.Property,
key: convertChild(node.name),
value: convertChild(node.name),
computed: false,
method: false,
shorthand: true,
kind: "init"
});
case SyntaxKind.ShorthandPropertyAssignment: {
if (node.objectAssignmentInitializer) {
Object.assign(result, {
type: AST_NODE_TYPES.Property,
key: convertChild(node.name),
value: {
type: AST_NODE_TYPES.AssignmentPattern,
left: convertChild(node.name),
right: convertChild(node.objectAssignmentInitializer),
loc: result.loc,
range: result.range
},
computed: false,
method: false,
shorthand: true,
kind: "init"
});
} else {
Object.assign(result, {
type: AST_NODE_TYPES.Property,
key: convertChild(node.name),
value: convertChild(node.initializer || node.name),
computed: false,
method: false,
shorthand: true,
kind: "init"
});
}
break;
}

case SyntaxKind.ComputedPropertyName:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({ foo = [] } = bar);
Loading