ts-morph
Expression With Type Arguments
These are found in certain areas. For example extends
and implements
expressions.
Getting expression
const expression = expressionWithTypeArgs.getExpression(); // returns: Node
Getting type arguments
const typeArgs = expressionWithTypeArgs.getTypeArguments(); // returns: TypeNode[]
Call Expressions
Call expressions are statements that call a function:
doSomething();
Getting call signatures
From a given node, get all the children or descendants that are call expressions.
For example:
const childCallExpressions = node.getChildrenOfKind(SyntaxKind.CallExpression);
const descendantCallExpressions = node.getDescendantsOfKind(SyntaxKind.CallExpression);
Return type
Use the following:
const returnType = callExpression.getReturnType();