Merge pull request #29082 from Microsoft/widenIntersectionTypes

Properly widen intersection types
This commit is contained in:
Anders Hejlsberg
2018-12-18 12:53:33 -08:00
committed by GitHub
5 changed files with 85 additions and 0 deletions

View File

@@ -13597,6 +13597,9 @@ namespace ts {
// union includes empty object types (e.g. reducing {} | string to just {}).
return getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? UnionReduction.Subtype : UnionReduction.Literal);
}
if (type.flags & TypeFlags.Intersection) {
return getIntersectionType(sameMap((<IntersectionType>type).types, getWidenedType));
}
if (isArrayType(type) || isTupleType(type)) {
return createTypeReference((<TypeReference>type).target, sameMap((<TypeReference>type).typeArguments, getWidenedType));
}