(t *Type, impliedType *Type, facts TypeFacts)
| 671 | } |
| 672 | |
| 673 | func (c *Checker) narrowTypeByTypeFacts(t *Type, impliedType *Type, facts TypeFacts) *Type { |
| 674 | return c.mapType(t, func(t *Type) *Type { |
| 675 | switch { |
| 676 | case c.isTypeRelatedTo(t, impliedType, c.strictSubtypeRelation): |
| 677 | if c.hasTypeFacts(t, facts) { |
| 678 | return t |
| 679 | } |
| 680 | return c.neverType |
| 681 | case c.isTypeSubtypeOf(impliedType, t): |
| 682 | return impliedType |
| 683 | case c.hasTypeFacts(t, facts): |
| 684 | return c.getIntersectionType([]*Type{t, impliedType}) |
| 685 | } |
| 686 | return c.neverType |
| 687 | }) |
| 688 | } |
| 689 | |
| 690 | func (c *Checker) narrowTypeByDiscriminantProperty(t *Type, access *ast.Node, operator ast.Kind, value *ast.Node, assumeTrue bool) *Type { |
| 691 | if (operator == ast.KindEqualsEqualsEqualsToken || operator == ast.KindExclamationEqualsEqualsToken) && t.flags&TypeFlagsUnion != 0 { |
no test coverage detected