@@ -18705,6 +18705,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18705
18705
result = target.objectFlags & ObjectFlags.Reference ? createDeferredTypeReference((type as DeferredTypeReference).target, (type as DeferredTypeReference).node, newMapper, newAliasSymbol, newAliasTypeArguments) :
18706
18706
target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(target as MappedType, newMapper, newAliasSymbol, newAliasTypeArguments) :
18707
18707
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
18708
+ // If none of the type arguments for the outer type parameters contain type variables, it follows
18709
+ // that the instantiated type doesn't reference type variables.
18710
+ if (result.flags & TypeFlags.ObjectFlagsType && !((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18711
+ (result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed |
18712
+ (some(typeArguments, couldContainTypeVariables) ? ObjectFlags.CouldContainTypeVariables : 0);
18713
+ }
18708
18714
target.instantiations.set(id, result);
18709
18715
}
18710
18716
return result;
@@ -18875,7 +18881,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18875
18881
}
18876
18882
18877
18883
function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): AnonymousType {
18878
- const result = createObjectType(type.objectFlags | ObjectFlags.Instantiated, type.symbol) as AnonymousType;
18884
+ const result = createObjectType(type.objectFlags & ~(ObjectFlags.CouldContainTypeVariablesComputed | ObjectFlags.CouldContainTypeVariables) | ObjectFlags.Instantiated, type.symbol) as AnonymousType;
18879
18885
if (type.objectFlags & ObjectFlags.Mapped) {
18880
18886
(result as MappedType).declaration = (type as MappedType).declaration;
18881
18887
// C.f. instantiateSignature
@@ -23887,7 +23893,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
23887
23893
}
23888
23894
const result = !!(type.flags & TypeFlags.Instantiable ||
23889
23895
type.flags & TypeFlags.Object && !isNonGenericTopLevelType(type) && (
23890
- objectFlags & ObjectFlags.Reference && ((type as TypeReference).node || forEach (getTypeArguments(type as TypeReference), couldContainTypeVariables)) ||
23896
+ objectFlags & ObjectFlags.Reference && ((type as TypeReference).node || some (getTypeArguments(type as TypeReference), couldContainTypeVariables)) ||
23891
23897
objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations ||
23892
23898
objectFlags & (ObjectFlags.Mapped | ObjectFlags.ReverseMapped | ObjectFlags.ObjectRestType | ObjectFlags.InstantiationExpressionType)) ||
23893
23899
type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && !isNonGenericTopLevelType(type) && some((type as UnionOrIntersectionType).types, couldContainTypeVariables));
0 commit comments