Skip to content

Commit 903c1d8

Browse files
committed
Add clarifying comment about checkExpressionCached
1 parent de8de7a commit 903c1d8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5949,6 +5949,12 @@ module ts {
59495949
}
59505950

59515951
function checkSpreadElementExpression(node: SpreadElementExpression, contextualMapper?: TypeMapper): Type {
5952+
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
5953+
// You can tell that we are contextually typing because of the contextualMapper parameter.
5954+
// While it is true that a spread element can have a contextual type, it does not do anything
5955+
// with this type. It is neither affected by it, nor does it propagate it to its operand.
5956+
// So the fact that contextualMapper is passed is not important, because the operand of a spread
5957+
// element is not contextually typed.
59525958
let arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
59535959
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
59545960
}

0 commit comments

Comments
 (0)