(f *FlowState, t *Type, callExpression *ast.Node, assumeTrue bool)
| 442 | } |
| 443 | |
| 444 | func (c *Checker) narrowTypeByCallExpression(f *FlowState, t *Type, callExpression *ast.Node, assumeTrue bool) *Type { |
| 445 | if c.hasMatchingArgument(callExpression, f.reference) { |
| 446 | var predicate *TypePredicate |
| 447 | if assumeTrue || !isCallChain(callExpression) { |
| 448 | signature := c.getEffectsSignature(callExpression) |
| 449 | if signature != nil { |
| 450 | predicate = c.getTypePredicateOfSignature(signature) |
| 451 | } |
| 452 | } |
| 453 | if predicate != nil && (predicate.kind == TypePredicateKindThis || predicate.kind == TypePredicateKindIdentifier) { |
| 454 | return c.narrowTypeByTypePredicate(f, t, predicate, callExpression, assumeTrue) |
| 455 | } |
| 456 | } |
| 457 | if c.containsMissingType(t) && ast.IsAccessExpression(f.reference) && ast.IsPropertyAccessExpression(callExpression.Expression()) { |
| 458 | callAccess := callExpression.Expression() |
| 459 | if c.isMatchingReference(f.reference.Expression(), c.getReferenceCandidate(callAccess.Expression())) && ast.IsIdentifier(callAccess.Name()) && callAccess.Name().Text() == "hasOwnProperty" && len(callExpression.Arguments()) == 1 { |
| 460 | argument := callExpression.Arguments()[0] |
| 461 | if accessedName, ok := c.getAccessedPropertyName(f.reference); ok && ast.IsStringLiteralLike(argument) && accessedName == argument.Text() { |
| 462 | return c.getTypeWithFacts(t, core.IfElse(assumeTrue, TypeFactsNEUndefined, TypeFactsEQUndefined)) |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | return t |
| 467 | } |
| 468 | |
| 469 | func (c *Checker) narrowTypeByBinaryExpression(f *FlowState, t *Type, expr *ast.BinaryExpression, assumeTrue bool) *Type { |
| 470 | switch expr.OperatorToken.Kind { |
no test coverage detected