No contextual types from circular mapped type properties (#38653)

* No contextual types from circular mapped type properties

* Add regression test
This commit is contained in:
Anders Hejlsberg
2020-05-19 13:42:30 -07:00
committed by GitHub
parent f7007174f6
commit 7ba0a6592d
5 changed files with 158 additions and 1 deletions

View File

@@ -22469,6 +22469,10 @@ namespace ts {
}
}
function isCircularMappedProperty(symbol: Symbol) {
return !!(getCheckFlags(symbol) & CheckFlags.Mapped && !(<MappedSymbol>symbol).type && findResolutionCycleStartIndex(symbol, TypeSystemPropertyName.Type) >= 0);
}
function getTypeOfPropertyOfContextualType(type: Type, name: __String) {
return mapType(type, t => {
if (isGenericMappedType(t)) {
@@ -22482,7 +22486,7 @@ namespace ts {
else if (t.flags & TypeFlags.StructuredType) {
const prop = getPropertyOfType(t, name);
if (prop) {
return getTypeOfSymbol(prop);
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
}
if (isTupleType(t)) {
const restType = getRestTypeOfTupleType(t);