Exclude T[K] assignability check from definitelyAssignableRelation

This commit is contained in:
Anders Hejlsberg
2018-11-28 14:56:49 -08:00
parent 52a46c6793
commit 01ee1b9c25

View File

@@ -12254,7 +12254,8 @@ namespace ts {
else if (target.flags & TypeFlags.IndexedAccess) {
// 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((<IndexedAccessType>target).objectType) && isGenericIndexType((<IndexedAccessType>target).indexType))) {
if (relation !== identityRelation && relation !== definitelyAssignableRelation &&
!(isGenericObjectType((<IndexedAccessType>target).objectType) && isGenericIndexType((<IndexedAccessType>target).indexType))) {
const constraint = getBaseConstraintOfType(target);
if (constraint && constraint !== target) {
if (result = isRelatedTo(source, constraint, reportErrors)) {