Skip to content

Commit

Permalink
Restrict to single-statement blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanCavanaugh committed Jan 9, 2025
1 parent 8b38313 commit 495ca92
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43942,7 +43942,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function checkBlock(node: Block) {
// Grammar checking for SyntaxKind.Block
if (node.statements.length === 1 && node.statements[0].kind === SyntaxKind.ExpressionStatement) {
if (isSideEffectFree((node.statements[0] as ExpressionStatement).expression)) {
error(node, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
}
}
if (node.kind === SyntaxKind.Block) {
checkGrammarStatementInAmbientContext(node);
}
Expand Down Expand Up @@ -44491,10 +44495,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// Grammar checking
checkGrammarStatementInAmbientContext(node);

if (isSideEffectFree(node.expression)) {
error(node, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
}

checkExpression(node.expression);
}

Expand Down

0 comments on commit 495ca92

Please sign in to comment.