Skip to content

Commit 2ba9ff1

Browse files
committed
Only check if the index type should be deferred for intersection types
1 parent 00e3926 commit 2ba9ff1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/compiler/checker.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -15903,13 +15903,10 @@ namespace ts {
1590315903
}
1590415904

1590515905
function distributeIndexOverObjectType(objectType: Type, indexType: Type, writing: boolean) {
15906-
if (shouldDeferIndexType(objectType)) {
15907-
return;
15908-
}
1590915906
// (T | U)[K] -> T[K] | U[K] (reading)
1591015907
// (T | U)[K] -> T[K] & U[K] (writing)
1591115908
// (T & U)[K] -> T[K] & U[K]
15912-
if (objectType.flags & TypeFlags.UnionOrIntersection) {
15909+
if (objectType.flags & TypeFlags.Union || objectType.flags & TypeFlags.Intersection && !shouldDeferIndexType(objectType)) {
1591315910
const types = map((objectType as UnionOrIntersectionType).types, t => getSimplifiedType(getIndexedAccessType(t, indexType), writing));
1591415911
return objectType.flags & TypeFlags.Intersection || writing ? getIntersectionType(types) : getUnionType(types);
1591515912
}

0 commit comments

Comments
 (0)