Microsoft/TypeScript — pull request #330 by ahejlsberg (2014-08-01 15:21:22+00:00)
Title: Pull model for contextual types

This pull request switches our contextual typing logic to use a “pull model” such that you can grab any expression node or symbol and ask for its type without having to first ensure types have been “pushed” into the right places. This includes contextually typed sub-expressions and contextually typed parameters of function expressions. We need this change to deliver correct results in the language service.

The key difference is a new `getContextualType` function that returns the contextual type associated with an arbitrary expression node with no requirement that the node or its containing function(s) have been fully type checked first. The methods works its way up the parent chain to compute the contextual type and binds contextually typed function expressions as necessary. Also, the types of contextually typed lambda parameters are computed on demand in a pull fashion so it is now safe to ask for the type of any symbol anywhere.