Skip to content

Commit 27675fc

Browse files
committed
Avoid failing TS2695 for eval.
1 parent fd80409 commit 27675fc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15929,7 +15929,7 @@ 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) && right.text!=="eval") {
1593315933
error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
1593415934
}
1593515935
return rightType;

tests/cases/compiler/evalAfter0.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(0,eval)("10");
2+
3+
(0,alert)("10");

0 commit comments

Comments
 (0)