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

Method isPartiallyInferableType

internal/checker/inference.go:1026–1030  ·  view source on GitHub ↗

We consider a type to be partially inferable if it isn't marked non-inferable or if it is an object literal type with at least one property of an inferable type. For example, an object literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive arrow function, bu

(t *Type)

Source from the content-addressed store, hash-verified

1024// literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive
1025// arrow function, but is considered partially inferable because property 'a' has an inferable type.
1026func (c *Checker) isPartiallyInferableType(t *Type) bool {
1027 return t.objectFlags&ObjectFlagsNonInferrableType == 0 || isObjectLiteralType(t) && core.Some(c.getPropertiesOfType(t), func(prop *ast.Symbol) bool {
1028 return c.isPartiallyInferableType(c.getTypeOfSymbol(prop))
1029 }) || isTupleType(t) && core.Some(c.getElementTypes(t), c.isPartiallyInferableType)
1030}
1031
1032func (c *Checker) inferReverseMappedType(source *Type, target *Type, constraint *Type) *Type {
1033 key := ReverseMappedTypeKey{sourceId: source.id, targetId: target.id, constraintId: constraint.id}

Callers 1

Calls 6

getPropertiesOfTypeMethod · 0.95
getTypeOfSymbolMethod · 0.95
getElementTypesMethod · 0.95
SomeFunction · 0.92
isObjectLiteralTypeFunction · 0.85
isTupleTypeFunction · 0.70

Tested by

no test coverage detected