@@ -7299,7 +7299,8 @@ namespace ts {
7299
7299
stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false);
7300
7300
}
7301
7301
}
7302
- const numberIndexInfo = symbol.flags & SymbolFlags.Enum ? enumNumberIndexInfo : undefined;
7302
+ const numberIndexInfo = symbol.flags & SymbolFlags.Enum && (getDeclaredTypeOfSymbol(symbol).flags & TypeFlags.Enum ||
7303
+ some(type.properties, prop => !!(getTypeOfSymbol(prop).flags & TypeFlags.NumberLike))) ? enumNumberIndexInfo : undefined;
7303
7304
setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
7304
7305
// We resolve the members before computing the signatures because a signature may use
7305
7306
// typeof with a qualified name expression that circularly references the type we are
@@ -8161,6 +8162,9 @@ namespace ts {
8161
8162
propTypes.push(getTypeOfSymbol(prop));
8162
8163
}
8163
8164
}
8165
+ if (kind === IndexKind.String) {
8166
+ append(propTypes, getIndexTypeOfType(type, IndexKind.Number));
8167
+ }
8164
8168
if (propTypes.length) {
8165
8169
return getUnionType(propTypes, UnionReduction.Subtype);
8166
8170
}
@@ -14498,7 +14502,7 @@ namespace ts {
14498
14502
* with no call or construct signatures.
14499
14503
*/
14500
14504
function isObjectTypeWithInferableIndex(type: Type) {
14501
- return type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral | SymbolFlags.ValueModule)) !== 0 &&
14505
+ return type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral | SymbolFlags.Enum| SymbolFlags. ValueModule)) !== 0 &&
14502
14506
!typeHasCallOrConstructSignatures(type);
14503
14507
}
14504
14508
0 commit comments