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
Conditionalize the carrying-forward of type variable containment checks
within `getObjectTypeInstantiation` more. The existing check pulls the
flags forward onto primitives/unions/intersections which may result from
`instantiateMappedType` unconditionally. This means we may mark unions
and intersections as possibly containing type parameters when they in
fact cannot.
target.instantiations.set(id, result); // Set cached result early in case we recursively invoke instantiation while eagerly computing type variable visibility below
18801
+
const resultObjectFlags = getObjectFlags(result);
18802
+
if (result.flags & TypeFlags.ObjectFlagsType && !(resultObjectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18803
+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables); // one of the input type arguments might be or contain the result
18804
+
if (!(getObjectFlags(result) & ObjectFlags.CouldContainTypeVariablesComputed)) {
18805
+
// if `result` is one of the object types we tried to make (it may not be, due to how `instantiateMappedType` works), we can carry forward the type variable containment check from the input type arguments
18806
+
if (resultObjectFlags & (ObjectFlags.Mapped | ObjectFlags.Anonymous | ObjectFlags.Reference)) {
// If none of the type arguments for the outer type parameters contain type variables, it follows
18810
+
// that the instantiated type doesn't reference type variables.
18811
+
// Intrinsics have `CouldContainTypeVariablesComputed` pre-set, so this should only cover unions and intersections resulting from `instantiateMappedType`
18812
+
else {
18813
+
(result as ObjectFlagsType).objectFlags |= !resultCouldContainTypeVariables ? ObjectFlags.CouldContainTypeVariablesComputed : 0;
0 commit comments