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 {
569
569
}
570
570
// We create a return control flow graph for IIFEs and constructors. For constructors
571
571
// 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 ;
573
573
currentBreakTarget = undefined ;
574
574
currentContinueTarget = undefined ;
575
575
activeLabels = undefined ;
@@ -589,9 +589,7 @@ namespace ts {
589
589
if ( currentReturnTarget ) {
590
590
addAntecedent ( currentReturnTarget , currentFlow ) ;
591
591
currentFlow = finishFlowLabel ( currentReturnTarget ) ;
592
- if ( node . kind === SyntaxKind . Constructor ) {
593
- ( < ConstructorDeclaration > node ) . returnFlowNode = currentFlow ;
594
- }
592
+ ( < FunctionLikeDeclaration > node ) . returnFlowNode = currentFlow ;
595
593
}
596
594
if ( ! isIIFE ) {
597
595
currentFlow = saveCurrentFlow ;
Original file line number Diff line number Diff line change @@ -23803,15 +23803,10 @@ namespace ts {
23803
23803
return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
23804
23804
}
23805
23805
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
-
23811
23806
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) ));
23815
23810
}
23816
23811
23817
23812
/** 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 {
1040
1040
questionToken ?: QuestionToken ;
1041
1041
exclamationToken ?: ExclamationToken ;
1042
1042
body ?: Block | Expression ;
1043
+ /* @internal */ returnFlowNode ?: FlowNode ;
1043
1044
}
1044
1045
1045
1046
export type FunctionLikeDeclaration =
@@ -1085,7 +1086,6 @@ namespace ts {
1085
1086
kind : SyntaxKind . Constructor ;
1086
1087
parent : ClassLikeDeclaration ;
1087
1088
body ?: FunctionBody ;
1088
- /* @internal */ returnFlowNode ?: FlowNode ;
1089
1089
}
1090
1090
1091
1091
/** 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