From 903c1d8dd8b1768f843be86d6fdf2b6da1a036df Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 26 Mar 2015 15:15:02 -0700 Subject: [PATCH] Add clarifying comment about checkExpressionCached --- src/compiler/checker.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 09674139c34..677361c196a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5949,6 +5949,12 @@ module ts { } function checkSpreadElementExpression(node: SpreadElementExpression, 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. let arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); }