Skip to content

Commit 97cb818

Browse files
committed
No contextual types from circular mapped type properties
1 parent 6ba8c27 commit 97cb818

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22469,6 +22469,10 @@ namespace ts {
2246922469
}
2247022470
}
2247122471

22472+
function isCircularMappedProperty(symbol: Symbol) {
22473+
return !!(getCheckFlags(symbol) & CheckFlags.Mapped && !(<MappedSymbol>symbol).type && findResolutionCycleStartIndex(symbol, TypeSystemPropertyName.Type) >= 0);
22474+
}
22475+
2247222476
function getTypeOfPropertyOfContextualType(type: Type, name: __String) {
2247322477
return mapType(type, t => {
2247422478
if (isGenericMappedType(t)) {
@@ -22482,7 +22486,7 @@ namespace ts {
2248222486
else if (t.flags & TypeFlags.StructuredType) {
2248322487
const prop = getPropertyOfType(t, name);
2248422488
if (prop) {
22485-
return getTypeOfSymbol(prop);
22489+
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
2248622490
}
2248722491
if (isTupleType(t)) {
2248822492
const restType = getRestTypeOfTupleType(t);

0 commit comments

Comments
 (0)