From 4268e13cde69c1d8a48788ef91d3b16669076522 Mon Sep 17 00:00:00 2001 From: Tycho Grouwstra Date: Mon, 14 Aug 2017 17:45:18 +0800 Subject: [PATCH] simplify fix as suggested by @ahejlsberg --- src/compiler/checker.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a85332d3de..9b274c4695 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18760,9 +18760,7 @@ namespace ts { } // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. - const typeOrConstraint = (tp: Type) => maybeTypeOfKind(tp, TypeFlags.TypeVariable) ? getBaseConstraintOfType(tp) || tp : tp; - if (isTypeAssignableToKind(typeOrConstraint(indexType), TypeFlags.NumberLike) && - getIndexInfoOfType(typeOrConstraint(objectType), IndexKind.Number)) { + if (getIndexInfoOfType(getApparentType(objectType), IndexKind.Number) && isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) { return type; } error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));