@@ -5761,6 +5761,9 @@ namespace ts {
5761
5761
}
5762
5762
}
5763
5763
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
5764
+ if (isTypeAny(objectType)) {
5765
+ return anyType;
5766
+ }
5764
5767
const indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike) && getIndexInfoOfType(objectType, IndexKind.Number) ||
5765
5768
getIndexInfoOfType(objectType, IndexKind.String) ||
5766
5769
undefined;
@@ -5772,7 +5775,7 @@ namespace ts {
5772
5775
return indexInfo.type;
5773
5776
}
5774
5777
if (accessExpression && !isConstEnumObjectType(objectType)) {
5775
- if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType) ) {
5778
+ if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
5776
5779
if (getIndexTypeOfType(objectType, IndexKind.Number)) {
5777
5780
error(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
5778
5781
}
@@ -5789,7 +5792,7 @@ namespace ts {
5789
5792
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, (<LiteralType>indexType).text, typeToString(objectType));
5790
5793
}
5791
5794
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));
5793
5796
}
5794
5797
else {
5795
5798
error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
0 commit comments