File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed
Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -15929,12 +15929,16 @@ namespace ts {
1592915929 checkAssignmentOperator(rightType);
1593015930 return getRegularTypeOfObjectLiteral(rightType);
1593115931 case SyntaxKind.CommaToken:
15932- if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) {
15932+ if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right) ) {
1593315933 error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
1593415934 }
1593515935 return rightType;
1593615936 }
1593715937
15938+ function isEvalNode(node: Expression) {
15939+ return node.kind === SyntaxKind.Identifier && (node as Identifier).text === "eval";
15940+ }
15941+
1593815942 // Return true if there was no error, false if there was an error.
1593915943 function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean {
1594015944 const offendingSymbolOperand =
Original file line number Diff line number Diff line change 1+ tests/cases/compiler/evalAfter0.ts(4,2): error TS2695: Left side of comma operator is unused and has no side effects.
2+
3+
4+ ==== tests/cases/compiler/evalAfter0.ts (1 errors) ====
5+ (0,eval)("10"); // fine: special case for eval
6+
7+ declare var eva;
8+ (0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something)
9+ ~
10+ !!! error TS2695: Left side of comma operator is unused and has no side effects.
Original file line number Diff line number Diff line change 1+ //// [evalAfter0.ts]
2+ ( 0 , eval ) ( "10" ) ; // fine: special case for eval
3+
4+ declare var eva ;
5+ ( 0 , eva ) ( "10" ) ; // error: no side effect left of comma (suspect of missing method name or something)
6+
7+ //// [evalAfter0.js]
8+ ( 0 , eval ) ( "10" ) ; // fine: special case for eval
9+ ( 0 , eva ) ( "10" ) ; // error: no side effect left of comma (suspect of missing method name or something)
Original file line number Diff line number Diff line change 1+ ( 0 , eval ) ( "10" ) ; // fine: special case for eval
2+
3+ declare var eva ;
4+ ( 0 , eva ) ( "10" ) ; // error: no side effect left of comma (suspect of missing method name or something)
You can’t perform that action at this time.
0 commit comments