(flow)
| 70435 | getAssignedType(node), reference); |
| 70436 | } |
| 70437 | function getTypeAtFlowAssignment(flow) { |
| 70438 | var node = flow.node; |
| 70439 | // Assignments only narrow the computed type if the declared type is a union type. Thus, we |
| 70440 | // only need to evaluate the assigned type if the declared type is a union type. |
| 70441 | if (isMatchingReference(reference, node)) { |
| 70442 | if (!isReachableFlowNode(flow)) { |
| 70443 | return unreachableNeverType; |
| 70444 | } |
| 70445 | if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { |
| 70446 | var flowType = getTypeAtFlowNode(flow.antecedent); |
| 70447 | return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); |
| 70448 | } |
| 70449 | if (declaredType === autoType || declaredType === autoArrayType) { |
| 70450 | if (isEmptyArrayAssignment(node)) { |
| 70451 | return getEvolvingArrayType(neverType); |
| 70452 | } |
| 70453 | var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); |
| 70454 | return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; |
| 70455 | } |
| 70456 | if (declaredType.flags & 1048576 /* TypeFlags.Union */) { |
| 70457 | return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); |
| 70458 | } |
| 70459 | return declaredType; |
| 70460 | } |
| 70461 | // We didn't have a direct match. However, if the reference is a dotted name, this |
| 70462 | // may be an assignment to a left hand part of the reference. For example, for a |
| 70463 | // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, |
| 70464 | // return the declared type. |
| 70465 | if (containsMatchingReference(reference, node)) { |
| 70466 | if (!isReachableFlowNode(flow)) { |
| 70467 | return unreachableNeverType; |
| 70468 | } |
| 70469 | // A matching dotted name might also be an expando property on a function *expression*, |
| 70470 | // in which case we continue control flow analysis back to the function's declaration |
| 70471 | if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { |
| 70472 | var init = ts.getDeclaredExpandoInitializer(node); |
| 70473 | if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { |
| 70474 | return getTypeAtFlowNode(flow.antecedent); |
| 70475 | } |
| 70476 | } |
| 70477 | return declaredType; |
| 70478 | } |
| 70479 | // for (const _ in ref) acts as a nonnull on ref |
| 70480 | if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { |
| 70481 | return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); |
| 70482 | } |
| 70483 | // Assignment doesn't affect reference |
| 70484 | return undefined; |
| 70485 | } |
| 70486 | function narrowTypeByAssertion(type, expr) { |
| 70487 | var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); |
| 70488 | if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { |
no test coverage detected
searching dependent graphs…