From 55d4d7b5c637c33f175b22458df3ff2302474621 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Jun 2018 08:57:15 -0700 Subject: [PATCH] Simplify nested indexed access types --- src/compiler/checker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9306907b418..b1ac56d66eb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8881,7 +8881,9 @@ namespace ts { return type.simplified === circularConstraintType ? type : type.simplified; } type.simplified = circularConstraintType; - const objectType = type.objectType; + // We recursively simplify the object type as it may in turn be an indexed access type. For example, with + // '{ [P in T]: { [Q in U]: number } }[T][U]' we want to first simplify the inner indexed access type. + const objectType = getSimplifiedType(type.objectType); if (objectType.flags & TypeFlags.Intersection && isGenericObjectType(objectType)) { // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a