Allow assignment expressions as destructuring assignment target

This commit is contained in:
Anders Hejlsberg 2014-11-30 09:11:18 -08:00
parent 501a3704f9
commit 3ff2a62892

View File

@ -6441,6 +6441,10 @@ module ts {
}
function checkDestructuringAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type {
if (target.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>target).operator === SyntaxKind.EqualsToken) {
checkBinaryExpression(<BinaryExpression>target, contextualMapper);
target = (<BinaryExpression>target).left;
}
if (target.kind === SyntaxKind.ObjectLiteral) {
return checkObjectLiteralAssignment(<ObjectLiteral>target, sourceType, contextualMapper);
}