Skip to content

Commit 505c153

Browse files
committed
Simplify isValidSpreadType
1 parent 2152683 commit 505c153

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11539,21 +11539,9 @@ namespace ts {
1153911539
}
1154011540

1154111541
function isValidSpreadType(type: Type): boolean {
11542-
if (type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined)) {
11543-
return true;
11544-
}
11545-
if (type.flags & TypeFlags.Object) {
11546-
return !isGenericMappedType(type);
11547-
}
11548-
else if (type.flags & TypeFlags.UnionOrIntersection) {
11549-
for (const t of (<UnionOrIntersectionType>type).types) {
11550-
if (!isValidSpreadType(t)) {
11551-
return false;
11552-
}
11553-
}
11554-
return true;
11555-
}
11556-
return false;
11542+
return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined) ||
11543+
type.flags & TypeFlags.Object && !isGenericMappedType(type) ||
11544+
type.flags & TypeFlags.UnionOrIntersection && !forEach((<UnionOrIntersectionType>type).types, t => !isValidSpreadType(t)));
1155711545
}
1155811546

1155911547
function checkJsxSelfClosingElement(node: JsxSelfClosingElement) {

0 commit comments

Comments
 (0)