Skip to content

Commit 70fc25a

Browse files
committed
Minor fixes
1 parent 663985e commit 70fc25a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5761,6 +5761,9 @@ namespace ts {
57615761
}
57625762
}
57635763
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
5764+
if (isTypeAny(objectType)) {
5765+
return anyType;
5766+
}
57645767
const indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike) && getIndexInfoOfType(objectType, IndexKind.Number) ||
57655768
getIndexInfoOfType(objectType, IndexKind.String) ||
57665769
undefined;
@@ -5772,7 +5775,7 @@ namespace ts {
57725775
return indexInfo.type;
57735776
}
57745777
if (accessExpression && !isConstEnumObjectType(objectType)) {
5775-
if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) {
5778+
if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
57765779
if (getIndexTypeOfType(objectType, IndexKind.Number)) {
57775780
error(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
57785781
}
@@ -5789,7 +5792,7 @@ namespace ts {
57895792
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, (<LiteralType>indexType).text, typeToString(objectType));
57905793
}
57915794
else if (indexType.flags & (TypeFlags.String | TypeFlags.Number)) {
5792-
error(accessNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
5795+
error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
57935796
}
57945797
else {
57955798
error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));

0 commit comments

Comments
 (0)