From c0c215fb668590f7d469c4f5931adc465710ce22 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 1 Oct 2018 16:20:15 -0700 Subject: [PATCH] No unsound assignments to T[K] when T and K are both generic --- src/compiler/checker.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 611b6c4d4b0..58e6075198a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11876,8 +11876,9 @@ namespace ts { } } else if (target.flags & TypeFlags.IndexedAccess) { - // 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] - if (relation !== identityRelation) { + // 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, + // where C is the base constraint of T[K] + if (relation !== identityRelation && !(isGenericObjectType((target).objectType) && isGenericIndexType((target).indexType))) { const constraint = getBaseConstraintOfType(target); if (constraint && constraint !== target) { if (result = isRelatedTo(source, constraint, reportErrors)) {