mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Simplify rules for isControlFlowEndingStatement (#25693)
This commit is contained in:
@@ -579,17 +579,10 @@ namespace ts.formatting {
|
||||
function isControlFlowEndingStatement(kind: SyntaxKind, parent: TextRangeWithKind): boolean {
|
||||
switch (kind) {
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.ThrowStatement: {
|
||||
if (parent.kind !== SyntaxKind.Block) {
|
||||
return true;
|
||||
}
|
||||
const grandParent = (parent as Node).parent;
|
||||
// In a function, we may want to write inner functions after this.
|
||||
return !(grandParent && grandParent.kind === SyntaxKind.FunctionExpression || grandParent.kind === SyntaxKind.FunctionDeclaration);
|
||||
}
|
||||
case SyntaxKind.ThrowStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.BreakStatement:
|
||||
return true;
|
||||
return parent.kind !== SyntaxKind.Block;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user