mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Preserve special intersections in mapped types (#50704)
* Preserve special intersections in mapped types * Add regression test
This commit is contained in:
@@ -11780,6 +11780,12 @@ namespace ts {
|
||||
return mapType(type as UnionType, getLowerBoundOfKeyType);
|
||||
}
|
||||
if (type.flags & TypeFlags.Intersection) {
|
||||
// Similarly to getTypeFromIntersectionTypeNode, we preserve the special string & {}, number & {},
|
||||
// and bigint & {} intersections that are used to prevent subtype reduction in union types.
|
||||
const types = (type as IntersectionType).types;
|
||||
if (types.length === 2 && !!(types[0].flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.BigInt)) && types[1] === emptyTypeLiteralType) {
|
||||
return type;
|
||||
}
|
||||
return getIntersectionType(sameMap((type as UnionType).types, getLowerBoundOfKeyType));
|
||||
}
|
||||
return type;
|
||||
|
||||
Reference in New Issue
Block a user