From c52eb6cef3fc149b5e5729de5b2ed11e72e11cab Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 4 Dec 2016 07:43:10 -0800 Subject: [PATCH] Indexed access any[K] has type any --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 912db011904..903c8cfda1c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6033,6 +6033,9 @@ namespace ts { function getIndexedAccessType(objectType: Type, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) { if (maybeTypeOfKind(indexType, TypeFlags.TypeVariable | TypeFlags.Index) || isGenericMappedType(objectType)) { + if (objectType.flags & TypeFlags.Any) { + return objectType; + } // If the index type is generic or if the object type is a mapped type with a generic constraint, // we are performing a higher-order index access where we cannot meaningfully access the properties // of the object type. In those cases, we first check that the index type is assignable to 'keyof T'