Skip to content

Commit

Permalink
simplify fix as suggested by @ahejlsberg
Browse files Browse the repository at this point in the history
  • Loading branch information
KiaraGrouwstra committed Aug 14, 2017
1 parent 1d6863a commit 4268e13
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 4268e13

Please sign in to comment.