Skip to content

Commit eeaa6cb

Browse files
committed
prevent narrowed types from being added to unions after the narrowing if statement as they can lead to unnecessary reportUnknown.... errors
1 parent d32ac94 commit eeaa6cb

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

packages/pyright-internal/src/analyzer/codeFlowEngine.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,6 @@ export function getCodeFlowEngine(
935935
}
936936

937937
function getTypeFromBranchFlowNode(branchNode: FlowLabel): FlowNodeTypeResult {
938-
const typesToCombine: Type[] = [];
939-
940938
let sawIncomplete = false;
941939

942940
for (const antecedent of branchNode.antecedents) {
@@ -952,15 +950,8 @@ export function getCodeFlowEngine(
952950
if (flowTypeResult.isIncomplete) {
953951
sawIncomplete = true;
954952
}
955-
956-
if (flowTypeResult.type) {
957-
typesToCombine.push(flowTypeResult.type);
958-
}
959953
}
960-
961-
const effectiveType = typesToCombine.length > 0 ? combineTypes(typesToCombine) : undefined;
962-
963-
return setCacheEntry(branchNode, effectiveType, sawIncomplete);
954+
return setCacheEntry(branchNode, NeverType.createNever(), sawIncomplete);
964955
}
965956

966957
function getTypeFromLoopFlowNode(

0 commit comments

Comments
 (0)