From d1259a11889e06df3bac12e9257bb510df3f24d7 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 7 Jun 2023 15:13:50 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#54507=20(Ensure=20w?= =?UTF-8?q?e=20don't=20overwrite=20computed=20...)=20into=20release-5.1=20?= =?UTF-8?q?(#54545)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- src/compiler/checker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0715f58e714..59e5c3e8aee 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18768,8 +18768,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // If none of the type arguments for the outer type parameters contain type variables, it follows // that the instantiated type doesn't reference type variables. if (result.flags & TypeFlags.ObjectFlagsType && !((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) { - (result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | - (some(typeArguments, couldContainTypeVariables) ? ObjectFlags.CouldContainTypeVariables : 0); + const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables); + // The above check may have caused the result's objectFlags to update if the result is referenced via typeArguments. + if (!((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) { + (result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | + (resultCouldContainTypeVariables ? ObjectFlags.CouldContainTypeVariables : 0); + } } target.instantiations.set(id, result); }