* Returns the type of an expression. Unlike checkExpression, this function is simply concerned * with computing the type and may not fully check all contained sub-expressions for errors.
(node)
| 79778 | * with computing the type and may not fully check all contained sub-expressions for errors. |
| 79779 | */ |
| 79780 | function getTypeOfExpression(node) { |
| 79781 | // Don't bother caching types that require no flow analysis and are quick to compute. |
| 79782 | var quickType = getQuickTypeOfExpression(node); |
| 79783 | if (quickType) { |
| 79784 | return quickType; |
| 79785 | } |
| 79786 | // If a type has been cached for the node, return it. |
| 79787 | if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { |
| 79788 | var cachedType = flowTypeCache[getNodeId(node)]; |
| 79789 | if (cachedType) { |
| 79790 | return cachedType; |
| 79791 | } |
| 79792 | } |
| 79793 | var startInvocationCount = flowInvocationCount; |
| 79794 | var type = checkExpression(node); |
| 79795 | // If control flow analysis was required to determine the type, it is worth caching. |
| 79796 | if (flowInvocationCount !== startInvocationCount) { |
| 79797 | var cache = flowTypeCache || (flowTypeCache = []); |
| 79798 | cache[getNodeId(node)] = type; |
| 79799 | ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); |
| 79800 | } |
| 79801 | return type; |
| 79802 | } |
| 79803 | function getQuickTypeOfExpression(node) { |
| 79804 | var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); |
| 79805 | if (ts.isJSDocTypeAssertion(expr)) { |
no test coverage detected
searching dependent graphs…