Skip to content

Commit 9d48047

Browse files
committed
check if instantiable type constraint allows spread
1 parent aa0e64a commit 9d48047

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19222,6 +19222,12 @@ namespace ts {
1922219222
}
1922319223

1922419224
function isValidSpreadType(type: Type): boolean {
19225+
if (type.flags & TypeFlags.Instantiable) {
19226+
const constraint = getBaseConstraintOfType(type);
19227+
if (constraint !== undefined) {
19228+
return isValidSpreadType(constraint);
19229+
}
19230+
}
1922519231
return !!(type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.NonPrimitive | TypeFlags.Object | TypeFlags.InstantiableNonPrimitive) ||
1922619232
getFalsyFlags(type) & TypeFlags.DefinitelyFalsy && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
1922719233
type.flags & TypeFlags.UnionOrIntersection && every((<UnionOrIntersectionType>type).types, isValidSpreadType));

0 commit comments

Comments
 (0)