Skip to content

Commit 5c4f145

Browse files
committed
Change name of the function
1 parent 5c10764 commit 5c4f145

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/compiler/checker.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,7 +3098,7 @@ namespace ts {
30983098
let type: Type;
30993099
if (pattern.kind === SyntaxKind.ObjectBindingPattern) {
31003100
if (declaration.dotDotDotToken) {
3101-
if (isInvalidSpreadType(parentType)) {
3101+
if (!isValidSpreadType(parentType)) {
31023102
error(declaration, Diagnostics.Rest_types_may_only_be_created_from_object_types);
31033103
return unknownType;
31043104
}
@@ -11449,7 +11449,7 @@ namespace ts {
1144911449
typeFlags = 0;
1145011450
}
1145111451
const type = checkExpression((memberDecl as SpreadAssignment).expression);
11452-
if (!(type.flags & TypeFlags.Any) && isInvalidSpreadType(type)) {
11452+
if (!isValidSpreadType(type)) {
1145311453
error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
1145411454
return unknownType;
1145511455
}
@@ -11527,14 +11527,21 @@ namespace ts {
1152711527
}
1152811528
}
1152911529

11530-
function isInvalidSpreadType(type: Type): boolean {
11530+
function isValidSpreadType(type: Type): boolean {
11531+
if (type.flags & TypeFlags.Any) {
11532+
return true;
11533+
}
1153111534
if (type.flags & TypeFlags.Object) {
11532-
return isGenericMappedType(type);
11535+
return !isGenericMappedType(type);
1153311536
}
1153411537
else if (type.flags & TypeFlags.UnionOrIntersection) {
11535-
return forEach((<UnionOrIntersectionType>type).types, isInvalidSpreadType);
11538+
for (const t of (<UnionOrIntersectionType>type).types) {
11539+
if (!isValidSpreadType(t)) {
11540+
return false;
11541+
}
11542+
}
1153611543
}
11537-
return true;
11544+
return false;
1153811545
}
1153911546

1154011547
function checkJsxSelfClosingElement(node: JsxSelfClosingElement) {

0 commit comments

Comments
 (0)