@@ -161,7 +161,12 @@ namespace ts {
161161 IsObjectLiteralOrClassExpressionMethod = 1 << 7 ,
162162 }
163163
164- let flowNodeCreated : < T extends FlowNode > ( node : T ) => T = identity ;
164+ function initFlowNode < T extends FlowNode > ( node : T ) {
165+ Debug . attachFlowNodeDebugInfo ( node ) ;
166+ return node ;
167+ }
168+
169+ let flowNodeCreated : < T extends FlowNode > ( node : T ) => T = initFlowNode ;
165170
166171 const binder = createBinder ( ) ;
167172
@@ -238,6 +243,10 @@ namespace ts {
238243
239244 Symbol = objectAllocator . getSymbolConstructor ( ) ;
240245
246+ // Attach debugging information if necessary
247+ Debug . attachFlowNodeDebugInfo ( unreachableFlow ) ;
248+ Debug . attachFlowNodeDebugInfo ( reportedUnreachableFlow ) ;
249+
241250 if ( ! file . locals ) {
242251 bind ( file ) ;
243252 file . symbolCount = symbolCount ;
@@ -626,7 +635,7 @@ namespace ts {
626635 // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
627636 // similarly to break statements that exit to a label just past the statement body.
628637 if ( ! isIIFE ) {
629- currentFlow = { flags : FlowFlags . Start } ;
638+ currentFlow = initFlowNode ( { flags : FlowFlags . Start } ) ;
630639 if ( containerFlags & ( ContainerFlags . IsFunctionExpression | ContainerFlags . IsObjectLiteralOrClassExpressionMethod ) ) {
631640 currentFlow . node = < FunctionExpression | ArrowFunction | MethodDeclaration > node ;
632641 }
@@ -638,7 +647,7 @@ namespace ts {
638647 currentContinueTarget = undefined ;
639648 activeLabels = undefined ;
640649 hasExplicitReturn = false ;
641- flowNodeCreated = identity ;
650+ flowNodeCreated = initFlowNode ;
642651 bindChildren ( node ) ;
643652 // Reset all reachability check related flags on node (for incremental scenarios)
644653 node . flags &= ~ NodeFlags . ReachabilityAndEmitFlags ;
@@ -919,11 +928,11 @@ namespace ts {
919928 }
920929
921930 function createBranchLabel ( ) : FlowLabel {
922- return { flags : FlowFlags . BranchLabel , antecedents : undefined } ;
931+ return initFlowNode ( { flags : FlowFlags . BranchLabel , antecedents : undefined } ) ;
923932 }
924933
925934 function createLoopLabel ( ) : FlowLabel {
926- return { flags : FlowFlags . LoopLabel , antecedents : undefined } ;
935+ return initFlowNode ( { flags : FlowFlags . LoopLabel , antecedents : undefined } ) ;
927936 }
928937
929938 function setFlowNodeReferenced ( flow : FlowNode ) {
@@ -1193,7 +1202,7 @@ namespace ts {
11931202 // as possible antecedents of the start of the `catch` or `finally` blocks.
11941203 // Don't bother intercepting the call if there's no finally or catch block that needs the information
11951204 if ( node . catchClause || node . finallyBlock ) {
1196- flowNodeCreated = node => ( tryPriors . push ( node ) , node ) ;
1205+ flowNodeCreated = node => ( tryPriors . push ( node ) , initFlowNode ( node ) ) ;
11971206 }
11981207 bind ( node . tryBlock ) ;
11991208 flowNodeCreated = oldFlowNodeCreated ;
@@ -1262,7 +1271,7 @@ namespace ts {
12621271 //
12631272 // extra edges that we inject allows to control this behavior
12641273 // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped.
1265- const preFinallyFlow : PreFinallyFlow = { flags : FlowFlags . PreFinally , antecedent : preFinallyPrior , lock : { } } ;
1274+ const preFinallyFlow : PreFinallyFlow = initFlowNode ( { flags : FlowFlags . PreFinally , antecedent : preFinallyPrior , lock : { } } ) ;
12661275 addAntecedent ( preFinallyLabel , preFinallyFlow ) ;
12671276
12681277 currentFlow = finishFlowLabel ( preFinallyLabel ) ;
@@ -1983,7 +1992,7 @@ namespace ts {
19831992 const host = getJSDocHost ( typeAlias ) ;
19841993 container = findAncestor ( host . parent , n => ! ! ( getContainerFlags ( n ) & ContainerFlags . IsContainer ) ) || file ;
19851994 blockScopeContainer = getEnclosingBlockScopeContainer ( host ) || file ;
1986- currentFlow = { flags : FlowFlags . Start } ;
1995+ currentFlow = initFlowNode ( { flags : FlowFlags . Start } ) ;
19871996 parent = typeAlias ;
19881997 bind ( typeAlias . typeExpression ) ;
19891998 const declName = getNameOfDeclaration ( typeAlias ) ;
0 commit comments