mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 05:58:32 -06:00
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]
}
```
This commit is contained in:
parent
6aebe9b77e
commit
3d3429c896
@ -11244,13 +11244,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type {
|
||||
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
|
||||
// You can tell that we are contextually typing because of the contextualMapper parameter.
|
||||
// While it is true that a spread element can have a contextual type, it does not do anything
|
||||
// with this type. It is neither affected by it, nor does it propagate it to its operand.
|
||||
// So the fact that contextualMapper is passed is not important, because the operand of a spread
|
||||
// element is not contextually typed.
|
||||
const arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
|
||||
const arrayOrIterableType = checkExpression(node.expression, contextualMapper);
|
||||
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user