File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -565,15 +565,26 @@ namespace ts.formatting {
565565 function isControlFlowEndingStatement ( kind : SyntaxKind , parent : TextRangeWithKind ) : boolean {
566566 switch ( kind ) {
567567 case SyntaxKind . ReturnStatement :
568- case SyntaxKind . ThrowStatement : {
569- const parentKind = parent . kind as StatementOnly [ "parent" ] [ "kind" ] ;
570- if ( parentKind !== SyntaxKind . Block ) {
571- return true ;
568+ case SyntaxKind . ThrowStatement :
569+ switch ( parent . kind ) {
570+ case SyntaxKind . Block :
571+ const grandParent = ( parent as Node ) . parent ;
572+ switch ( grandParent && grandParent . kind ) {
573+ case SyntaxKind . FunctionDeclaration :
574+ case SyntaxKind . FunctionExpression :
575+ // We may want to write inner functions after this.
576+ return false ;
577+ default :
578+ return true ;
579+ }
580+ case SyntaxKind . CaseClause :
581+ case SyntaxKind . DefaultClause :
582+ case SyntaxKind . SourceFile :
583+ case SyntaxKind . ModuleBlock :
584+ return true ;
585+ default :
586+ throw Debug . fail ( ) ;
572587 }
573- const grandParent = ( parent as Node ) . parent ;
574- // In a function, we may want to write inner functions after this.
575- return ! ( grandParent && grandParent . kind === SyntaxKind . FunctionExpression || grandParent . kind === SyntaxKind . FunctionDeclaration ) ;
576- }
577588 case SyntaxKind . ContinueStatement :
578589 case SyntaxKind . BreakStatement :
579590 return true ;
You can’t perform that action at this time.
0 commit comments