Avoid creating rest elements with errorType when any is spread (#57116)

This commit is contained in:
Mateusz Burzyński
2024-02-16 23:05:33 +01:00
committed by GitHub
parent c18c1c20dc
commit 29c0024bcf
13 changed files with 189 additions and 10 deletions

View File

@@ -16883,7 +16883,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const type = elementTypes[i];
const flags = target.elementFlags[i];
if (flags & ElementFlags.Variadic) {
if (type.flags & TypeFlags.InstantiableNonPrimitive || isGenericMappedType(type)) {
if (type.flags & TypeFlags.Any) {
addElement(type, ElementFlags.Rest, target.labeledElementDeclarations?.[i]);
}
else if (type.flags & TypeFlags.InstantiableNonPrimitive || isGenericMappedType(type)) {
// Generic variadic elements stay as they are.
addElement(type, ElementFlags.Variadic, target.labeledElementDeclarations?.[i]);
}