Merge pull request #21947 from Microsoft/fixKeyofWildcard

Fix issue with 'keyof T' and conditional types
This commit is contained in:
Anders Hejlsberg
2018-02-15 12:44:51 -08:00
committed by GitHub
6 changed files with 316 additions and 0 deletions

View File

@@ -7949,6 +7949,7 @@ namespace ts {
function getIndexType(type: Type): Type {
return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive) ? getIndexTypeForGenericType(<InstantiableType | UnionOrIntersectionType>type) :
getObjectFlags(type) & ObjectFlags.Mapped ? getConstraintTypeFromMappedType(<MappedType>type) :
type === wildcardType ? wildcardType :
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringType :
getLiteralTypeFromPropertyNames(type);
}