Merge pull request #22300 from Microsoft/distributeKeyofIntersection

Distribute 'keyof' intersection types
This commit is contained in:
Anders Hejlsberg
2018-03-02 16:08:20 -08:00
committed by GitHub
9 changed files with 328 additions and 30 deletions

View File

@@ -8007,7 +8007,8 @@ namespace ts {
}
function getIndexType(type: Type): Type {
return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive) ? getIndexTypeForGenericType(<InstantiableType | UnionOrIntersectionType>type) :
return type.flags & TypeFlags.Intersection ? getUnionType(map((<IntersectionType>type).types, t => getIndexType(t))) :
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 :