File tree Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -569,7 +569,7 @@ namespace ts {
569569 }
570570 // We create a return control flow graph for IIFEs and constructors. For constructors
571571 // we use the return control flow graph in strict property initialization checks.
572- currentReturnTarget = isIIFE || node . kind === SyntaxKind . Constructor ? createBranchLabel ( ) : undefined ;
572+ currentReturnTarget = containerFlags & ContainerFlags . IsFunctionLike && nodeIsPresent ( ( < FunctionLikeDeclaration > node ) . body ) ? createBranchLabel ( ) : undefined ;
573573 currentBreakTarget = undefined ;
574574 currentContinueTarget = undefined ;
575575 activeLabels = undefined ;
@@ -589,9 +589,7 @@ namespace ts {
589589 if ( currentReturnTarget ) {
590590 addAntecedent ( currentReturnTarget , currentFlow ) ;
591591 currentFlow = finishFlowLabel ( currentReturnTarget ) ;
592- if ( node . kind === SyntaxKind . Constructor ) {
593- ( < ConstructorDeclaration > node ) . returnFlowNode = currentFlow ;
594- }
592+ ( < FunctionLikeDeclaration > node ) . returnFlowNode = currentFlow ;
595593 }
596594 if ( ! isIIFE ) {
597595 currentFlow = saveCurrentFlow ;
Original file line number Diff line number Diff line change @@ -23803,15 +23803,10 @@ namespace ts {
2380323803 return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
2380423804 }
2380523805
23806- function isNeverFunctionCall(expr: Expression) {
23807- const signature = expr.kind === SyntaxKind.CallExpression && getEffectsSignature(<CallExpression>expr);
23808- return !!(signature && getReturnTypeOfSignature(signature).flags & TypeFlags.Never);
23809- }
23810-
2381123806 function functionHasImplicitReturn(func: FunctionLikeDeclaration) {
23812- return !!(func.flags & NodeFlags.HasImplicitReturn) && !some((<Block>func.body).statements, statement =>
23813- statement. kind === SyntaxKind.SwitchStatement && isExhaustiveSwitchStatement(<SwitchStatement>statement) ||
23814- statement.kind === SyntaxKind.ExpressionStatement && isNeverFunctionCall((<ExpressionStatement>statement).expression ));
23807+ return !!(func.flags & NodeFlags.HasImplicitReturn &&
23808+ !some((<Block>func.body).statements, s => s. kind === SyntaxKind.SwitchStatement && isExhaustiveSwitchStatement(<SwitchStatement>s)) &&
23809+ !(func.returnFlowNode && !isReachableFlowNode(func.returnFlowNode) ));
2381523810 }
2381623811
2381723812 /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */
Original file line number Diff line number Diff line change @@ -1040,6 +1040,7 @@ namespace ts {
10401040 questionToken ?: QuestionToken ;
10411041 exclamationToken ?: ExclamationToken ;
10421042 body ?: Block | Expression ;
1043+ /* @internal */ returnFlowNode ?: FlowNode ;
10431044 }
10441045
10451046 export type FunctionLikeDeclaration =
@@ -1085,7 +1086,6 @@ namespace ts {
10851086 kind : SyntaxKind . Constructor ;
10861087 parent : ClassLikeDeclaration ;
10871088 body ?: FunctionBody ;
1088- /* @internal */ returnFlowNode ?: FlowNode ;
10891089 }
10901090
10911091 /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */
You can’t perform that action at this time.
0 commit comments