mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 01:33:15 -05:00
Avoid infinite recursion when instantiating circular inline mapped generic tuple type (#53522)
This commit is contained in:
committed by
GitHub
parent
fefcb81d48
commit
7baf6cd120
@@ -18926,6 +18926,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const singleton = elementFlags[i] & ElementFlags.Variadic ? t :
|
||||
elementFlags[i] & ElementFlags.Rest ? createArrayType(t) :
|
||||
createTupleType([t], [elementFlags[i]]);
|
||||
// avoid infinite recursion, if the singleton is the type variable itself
|
||||
// then we'd just get back here with the same arguments from within instantiateMappedType
|
||||
if (singleton === typeVariable) {
|
||||
return mappedType;
|
||||
}
|
||||
// The singleton is never a generic tuple type, so it is safe to recurse here.
|
||||
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user