Fix 'keyof any' to produce 'string | number'

This commit is contained in:
Anders Hejlsberg 2016-11-01 16:59:53 -07:00
parent 41c20545e1
commit 663985eed0

View File

@ -5713,7 +5713,7 @@ namespace ts {
function getIndexType(type: Type): Type {
return type.flags & TypeFlags.TypeParameter ? getIndexTypeForTypeParameter(<TypeParameter>type) :
getIndexInfoOfType(type, IndexKind.String) ? stringOrNumberType :
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringOrNumberType :
getIndexInfoOfType(type, IndexKind.Number) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) :
getLiteralTypeFromPropertyNames(type);
}