MCPcopy Index your code
hub / github.com/nodejs/node / getQuickTypeOfExpression

Function getQuickTypeOfExpression

test/fixtures/snapshot/typescript.js:79803–79829  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

79801 return type;
79802 }
79803 function getQuickTypeOfExpression(node) {
79804 var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
79805 if (ts.isJSDocTypeAssertion(expr)) {
79806 var type = ts.getJSDocTypeAssertionType(expr);
79807 if (!ts.isConstTypeReference(type)) {
79808 return getTypeFromTypeNode(type);
79809 }
79810 }
79811 expr = ts.skipParentheses(node);
79812 // Optimize for the common case of a call to a function with a single non-generic call
79813 // signature where we can just fetch the return type without checking the arguments.
79814 if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
79815 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
79816 getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
79817 if (type) {
79818 return type;
79819 }
79820 }
79821 else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
79822 return getTypeFromTypeNode(expr.type);
79823 }
79824 else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ ||
79825 node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) {
79826 return checkExpression(node);
79827 }
79828 return undefined;
79829 }
79830 /**
79831 * Returns the type of an expression. Unlike checkExpression, this function is simply concerned
79832 * with computing the type and may not fully check all contained sub-expressions for errors.

Callers 2

getTypeOfExpressionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…