mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Better check for right.text, more comments in test
This commit is contained in:
parent
27675fc96e
commit
6a88cf0edf
@ -15929,12 +15929,16 @@ namespace ts {
|
||||
checkAssignmentOperator(rightType);
|
||||
return getRegularTypeOfObjectLiteral(rightType);
|
||||
case SyntaxKind.CommaToken:
|
||||
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && right.text!=="eval") {
|
||||
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 =
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
(0,eval)("10");
|
||||
(0,eval)("10"); // fine: special case for eval
|
||||
|
||||
(0,alert)("10");
|
||||
(0,alert)("10"); // error: no side effect left of comma (suspect of missing method name or something)
|
||||
Loading…
x
Reference in New Issue
Block a user