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

Method getSingleCommonSupertype

internal/checker/inference.go:1523–1532  ·  view source on GitHub ↗
(types []*Type)

Source from the content-addressed store, hash-verified

1521}
1522
1523func (c *Checker) getSingleCommonSupertype(types []*Type) *Type {
1524 // First, find the leftmost type for which no type to the right is a strict supertype, and if that
1525 // type is a strict supertype of all other candidates, return it. Otherwise, return the leftmost type
1526 // for which no type to the right is a (regular) supertype.
1527 candidate := c.findLeftmostType(types, (*Checker).isTypeStrictSubtypeOf)
1528 if core.Every(types, func(t *Type) bool { return t == candidate || c.isTypeStrictSubtypeOf(t, candidate) }) {
1529 return candidate
1530 }
1531 return c.findLeftmostType(types, (*Checker).isTypeSubtypeOf)
1532}
1533
1534func (c *Checker) findLeftmostType(types []*Type, f func(c *Checker, s *Type, t *Type) bool) *Type {
1535 var candidate *Type

Callers 1

getCommonSupertypeMethod · 0.95

Calls 3

findLeftmostTypeMethod · 0.95
isTypeStrictSubtypeOfMethod · 0.95
EveryFunction · 0.92

Tested by

no test coverage detected