Skip to content

Commit c0c215f

Browse files
committed
No unsound assignments to T[K] when T and K are both generic
1 parent 21148b3 commit c0c215f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/compiler/checker.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -11876,8 +11876,9 @@ namespace ts {
1187611876
}
1187711877
}
1187811878
else if (target.flags & TypeFlags.IndexedAccess) {
11879-
// A type S is related to a type T[K] if S is related to C, where C is the base constraint of T[K]
11880-
if (relation !== identityRelation) {
11879+
// A type S is related to a type T[K], where T and K aren't both type variables, if S is related to C,
11880+
// where C is the base constraint of T[K]
11881+
if (relation !== identityRelation && !(isGenericObjectType((<IndexedAccessType>target).objectType) && isGenericIndexType((<IndexedAccessType>target).indexType))) {
1188111882
const constraint = getBaseConstraintOfType(target);
1188211883
if (constraint && constraint !== target) {
1188311884
if (result = isRelatedTo(source, constraint, reportErrors)) {

0 commit comments

Comments
 (0)