You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add missing mapped type indexed access constraint (#47370)
* Type { [P in K]: E }[X] has constraint E with X substutited for P
* Add regression test
* Fix PragmaMap and ReadonlyPragmaMap declarations
* Explore additional constraint
* Revert previous change
* Add tests
// We obtain the base constraint for all instantiable types, except indexed access types of the form
12059
-
// { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
12060
-
// instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
12061
-
// lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
12062
-
const t = !(type.flags & TypeFlags.Instantiable) ? type :
12063
-
isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType((type as IndexedAccessType).objectType as MappedType, (type as IndexedAccessType).indexType) :
12064
-
getBaseConstraintOfType(type) || unknownType;
12068
+
const t = !(type.flags & TypeFlags.Instantiable) ? type : getBaseConstraintOfType(type) || unknownType;
12065
12069
return getObjectFlags(t) & ObjectFlags.Mapped ? getApparentTypeOfMappedType(t as MappedType) :
12066
12070
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t as IntersectionType) :
0 commit comments