MCPcopy Index your code
hub / github.com/nodejs/node / getTypeAtFlowCondition

Function getTypeAtFlowCondition

test/fixtures/snapshot/typescript.js:70550–70570  ·  view source on GitHub ↗
(flow)

Source from the content-addressed store, hash-verified

70548 return undefined;
70549 }
70550 function getTypeAtFlowCondition(flow) {
70551 var flowType = getTypeAtFlowNode(flow.antecedent);
70552 var type = getTypeFromFlowType(flowType);
70553 if (type.flags & 131072 /* TypeFlags.Never */) {
70554 return flowType;
70555 }
70556 // If we have an antecedent type (meaning we're reachable in some way), we first
70557 // attempt to narrow the antecedent type. If that produces the never type, and if
70558 // the antecedent type is incomplete (i.e. a transient type in a loop), then we
70559 // take the type guard as an indication that control *could* reach here once we
70560 // have the complete type. We proceed by switching to the silent never type which
70561 // doesn't report errors when operators are applied to it. Note that this is the
70562 // *only* place a silent never type is ever generated.
70563 var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0;
70564 var nonEvolvingType = finalizeEvolvingArrayType(type);
70565 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
70566 if (narrowedType === nonEvolvingType) {
70567 return flowType;
70568 }
70569 return createFlowType(narrowedType, isIncomplete(flowType));
70570 }
70571 function getTypeAtSwitchClause(flow) {
70572 var expr = flow.switchStatement.expression;
70573 var flowType = getTypeAtFlowNode(flow.antecedent);

Callers 1

getTypeAtFlowNodeFunction · 0.85

Calls 6

getTypeAtFlowNodeFunction · 0.85
getTypeFromFlowTypeFunction · 0.85
narrowTypeFunction · 0.85
createFlowTypeFunction · 0.85
isIncompleteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…