Skip to content

Commit a52805f

Browse files
committed
Use checkExpression in checkSpreadExpression
Not checkExpressionCached. checkExpressionCached ignores ongoing control flow analysis, which causes the following loop to make the compiler recur infinitely: ```ts let a = [] for (const x of []) { a = [...a] } ```
1 parent f79fca7 commit a52805f

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11252,13 +11252,7 @@ namespace ts {
1125211252
}
1125311253

1125411254
function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type {
11255-
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
11256-
// You can tell that we are contextually typing because of the contextualMapper parameter.
11257-
// While it is true that a spread element can have a contextual type, it does not do anything
11258-
// with this type. It is neither affected by it, nor does it propagate it to its operand.
11259-
// So the fact that contextualMapper is passed is not important, because the operand of a spread
11260-
// element is not contextually typed.
11261-
const arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
11255+
const arrayOrIterableType = checkExpression(node.expression, contextualMapper);
1126211256
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
1126311257
}
1126411258

0 commit comments

Comments
 (0)