Add known keys of the mapped type constraint to its members (#50081)

* Add known keys of the mapped type constraint to its members

* Avoid second pass of adding known members by instead passing `noReductions` to `mapType`
This commit is contained in:
Mateusz Burzyński
2022-11-08 01:22:27 +01:00
committed by GitHub
parent 48aebcdcdb
commit 39ccac654c
5 changed files with 112 additions and 1 deletions

View File

@@ -12021,7 +12021,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return type;
}
if (type.flags & TypeFlags.Union) {
return mapType(type as UnionType, getLowerBoundOfKeyType);
return mapType(type as UnionType, getLowerBoundOfKeyType, /*noReductions*/ true);
}
if (type.flags & TypeFlags.Intersection) {
// Similarly to getTypeFromIntersectionTypeNode, we preserve the special string & {}, number & {},