Merge pull request #14324 from mihailik/master

Special-case (0,eval) for side-effect-free 0 left of comma
This commit is contained in:
Mohamed Hegazy
2017-02-27 11:32:11 -08:00
committed by GitHub
4 changed files with 28 additions and 1 deletions

View File

@@ -15929,12 +15929,16 @@ namespace ts {
checkAssignmentOperator(rightType);
return getRegularTypeOfObjectLiteral(rightType);
case SyntaxKind.CommaToken:
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) {
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
}
return rightType;
}
function isEvalNode(node: Expression) {
return node.kind === SyntaxKind.Identifier && (node as Identifier).text === "eval";
}
// Return true if there was no error, false if there was an error.
function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean {
const offendingSymbolOperand =