MCPcopy Create free account
hub / github.com/microsoft/typescript-go / inferToConditionalType

Method inferToConditionalType

internal/checker/inference.go:520–530  ·  view source on GitHub ↗
(n *InferenceState, source *Type, target *Type)

Source from the content-addressed store, hash-verified

518}
519
520func (c *Checker) inferToConditionalType(n *InferenceState, source *Type, target *Type) {
521 if source.flags&TypeFlagsConditional != 0 {
522 c.inferFromTypes(n, source.AsConditionalType().checkType, target.AsConditionalType().checkType)
523 c.inferFromTypes(n, source.AsConditionalType().extendsType, target.AsConditionalType().extendsType)
524 c.inferFromTypes(n, c.getTrueTypeFromConditionalType(source), c.getTrueTypeFromConditionalType(target))
525 c.inferFromTypes(n, c.getFalseTypeFromConditionalType(source), c.getFalseTypeFromConditionalType(target))
526 } else {
527 targetTypes := []*Type{c.getTrueTypeFromConditionalType(target), c.getFalseTypeFromConditionalType(target)}
528 c.inferToMultipleTypesWithPriority(n, source, targetTypes, target.flags, core.IfElse(n.contravariant, InferencePriorityContravariantConditional, 0))
529 }
530}
531
532func (c *Checker) inferToTemplateLiteralType(n *InferenceState, source *Type, target *TemplateLiteralType) {
533 matches := c.inferTypesFromTemplateLiteralType(source, target)

Callers

nothing calls this directly

Calls 6

inferFromTypesMethod · 0.95
IfElseFunction · 0.92
AsConditionalTypeMethod · 0.80

Tested by

no test coverage detected