Skip to content

Commit 4268e13

Browse files
simplify fix as suggested by @ahejlsberg
1 parent 1d6863a commit 4268e13

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18760,9 +18760,7 @@ namespace ts {
1876018760
}
1876118761
// Check if we're indexing with a numeric type and if either object or index types
1876218762
// is a generic type with a constraint that has a numeric index signature.
18763-
const typeOrConstraint = (tp: Type) => maybeTypeOfKind(tp, TypeFlags.TypeVariable) ? getBaseConstraintOfType(tp) || tp : tp;
18764-
if (isTypeAssignableToKind(typeOrConstraint(indexType), TypeFlags.NumberLike) &&
18765-
getIndexInfoOfType(typeOrConstraint(objectType), IndexKind.Number)) {
18763+
if (getIndexInfoOfType(getApparentType(objectType), IndexKind.Number) && isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) {
1876618764
return type;
1876718765
}
1876818766
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));

0 commit comments

Comments
 (0)