@@ -18686,6 +18686,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18686
18686
result = target.objectFlags & ObjectFlags.Reference ? createDeferredTypeReference((type as DeferredTypeReference).target, (type as DeferredTypeReference).node, newMapper, newAliasSymbol, newAliasTypeArguments) :
18687
18687
target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(target as MappedType, newMapper, newAliasSymbol, newAliasTypeArguments) :
18688
18688
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
18689
+ // If none of the type arguments for the outer type parameters contain type variables, it follows
18690
+ // that the instantiated type doesn't reference type variables.
18691
+ if (result.flags & TypeFlags.ObjectFlagsType && !((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18692
+ (result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed |
18693
+ (some(typeArguments, couldContainTypeVariables) ? ObjectFlags.CouldContainTypeVariables : 0);
18694
+ }
18689
18695
target.instantiations.set(id, result);
18690
18696
}
18691
18697
return result;
@@ -18856,7 +18862,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18856
18862
}
18857
18863
18858
18864
function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): AnonymousType {
18859
- const result = createObjectType(type.objectFlags | ObjectFlags.Instantiated, type.symbol) as AnonymousType;
18865
+ const result = createObjectType(type.objectFlags & ~(ObjectFlags.CouldContainTypeVariablesComputed | ObjectFlags.CouldContainTypeVariables) | ObjectFlags.Instantiated, type.symbol) as AnonymousType;
18860
18866
if (type.objectFlags & ObjectFlags.Mapped) {
18861
18867
(result as MappedType).declaration = (type as MappedType).declaration;
18862
18868
// C.f. instantiateSignature
@@ -23858,7 +23864,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
23858
23864
}
23859
23865
const result = !!(type.flags & TypeFlags.Instantiable ||
23860
23866
type.flags & TypeFlags.Object && !isNonGenericTopLevelType(type) && (
23861
- objectFlags & ObjectFlags.Reference && ((type as TypeReference).node || forEach (getTypeArguments(type as TypeReference), couldContainTypeVariables)) ||
23867
+ objectFlags & ObjectFlags.Reference && ((type as TypeReference).node || some (getTypeArguments(type as TypeReference), couldContainTypeVariables)) ||
23862
23868
objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations ||
23863
23869
objectFlags & (ObjectFlags.Mapped | ObjectFlags.ReverseMapped | ObjectFlags.ObjectRestType | ObjectFlags.InstantiationExpressionType)) ||
23864
23870
type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && !isNonGenericTopLevelType(type) && some((type as UnionOrIntersectionType).types, couldContainTypeVariables));
0 commit comments