simplify fix as suggested by @ahejlsberg
This commit is contained in:
parent
1d6863ab0b
commit
4268e13cde
1 changed files with 1 additions and 3 deletions
|
@ -18760,9 +18760,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
// Check if we're indexing with a numeric type and if either object or index types
|
// 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.
|
// 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 (getIndexInfoOfType(getApparentType(objectType), IndexKind.Number) && isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) {
|
||||||
if (isTypeAssignableToKind(typeOrConstraint(indexType), TypeFlags.NumberLike) &&
|
|
||||||
getIndexInfoOfType(typeOrConstraint(objectType), IndexKind.Number)) {
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||||
|
|
Loading…
Reference in a new issue