Skip to content

Commit d1259a1

Browse files
TypeScript Botjakebailey
TypeScript Bot
andauthored
🤖 Pick PR #54507 (Ensure we don't overwrite computed ...) into release-5.1 (#54545)
Co-authored-by: Jake Bailey <[email protected]>
1 parent b547906 commit d1259a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/compiler/checker.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -18768,8 +18768,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1876818768
// If none of the type arguments for the outer type parameters contain type variables, it follows
1876918769
// that the instantiated type doesn't reference type variables.
1877018770
if (result.flags & TypeFlags.ObjectFlagsType && !((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18771-
(result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed |
18772-
(some(typeArguments, couldContainTypeVariables) ? ObjectFlags.CouldContainTypeVariables : 0);
18771+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
18772+
// The above check may have caused the result's objectFlags to update if the result is referenced via typeArguments.
18773+
if (!((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18774+
(result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed |
18775+
(resultCouldContainTypeVariables ? ObjectFlags.CouldContainTypeVariables : 0);
18776+
}
1877318777
}
1877418778
target.instantiations.set(id, result);
1877518779
}

0 commit comments

Comments
 (0)