Skip to content

Commit 12b80f3

Browse files
committed
Keep string index from intersections in base constraint of index type
1 parent e3da8fb commit 12b80f3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/compiler/checker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6468,7 +6468,7 @@ namespace ts {
64686468
}
64696469

64706470
function getConstraintOfIndexedAccess(type: IndexedAccessType) {
6471-
const transformed = getSimplifiedIndexedAccessType(type);
6471+
const transformed = getSubstitutedIndexedMappedType(type);
64726472
if (transformed) {
64736473
return transformed;
64746474
}
@@ -8383,6 +8383,11 @@ namespace ts {
83838383
getIntersectionType(stringIndexTypes)
83848384
]);
83858385
}
8386+
return getSubstitutedIndexedMappedType(type);
8387+
}
8388+
8389+
function getSubstitutedIndexedMappedType(type: IndexedAccessType): Type {
8390+
const objectType = type.objectType;
83868391
// If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
83878392
// that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
83888393
// construct the type Box<T[X]>.

0 commit comments

Comments
 (0)