Properly handle mapped types with 'keyof any'

This commit is contained in:
Anders Hejlsberg
2017-10-13 16:54:57 -07:00
parent d940cdadfe
commit 07ff0fdb81

View File

@@ -5777,7 +5777,7 @@ namespace ts {
for (const propertySymbol of getPropertiesOfType(modifiersType)) {
addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol);
}
if (getIndexInfoOfType(modifiersType, IndexKind.String)) {
if (modifiersType.flags & TypeFlags.Any || getIndexInfoOfType(modifiersType, IndexKind.String)) {
addMemberForKeyType(stringType);
}
}
@@ -8386,7 +8386,7 @@ namespace ts {
}
function isMappableType(type: Type) {
return type.flags & (TypeFlags.TypeParameter | TypeFlags.Object | TypeFlags.Intersection | TypeFlags.IndexedAccess);
return type.flags & (TypeFlags.Any | TypeFlags.TypeParameter | TypeFlags.Object | TypeFlags.Intersection | TypeFlags.IndexedAccess);
}
function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): AnonymousType {