diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a0146740678..076abcba81b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -514,8 +514,9 @@ namespace ts { if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) { (currentFlow).container = node; } - currentReturnTarget = undefined; + currentReturnTarget = node.kind === SyntaxKind.Constructor ? createBranchLabel() : undefined; } + currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -535,6 +536,10 @@ namespace ts { currentFlow = finishFlowLabel(currentReturnTarget); } else { + if (node.kind === SyntaxKind.Constructor) { + addAntecedent(currentReturnTarget, currentFlow); + (node).returnFlowNode = currentFlow; + } currentFlow = saveCurrentFlow; } currentBreakTarget = saveBreakTarget; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3141e3f22d9..32d6dc72fb9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -929,6 +929,7 @@ namespace ts { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; + returnFlowNode?: FlowNode; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */