Skip to content

Commit 5d554a6

Browse files
Add arrow functions
1 parent 67edea6 commit 5d554a6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

extract.ts

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ function extractFunctionCalls(node: ts.Node, sourceFile: ts.SourceFile, indentLe
3434
});
3535
}
3636

37+
// Arrow function
38+
if (
39+
ts.isVariableDeclaration(node) &&
40+
node.initializer &&
41+
ts.isArrowFunction(node.initializer) &&
42+
indentLevel === 3
43+
) {
44+
const child = node.getChildAt(0, sourceFile);
45+
if (ts.isIdentifier(child)) {
46+
const declaredFunction: string = child.getText(sourceFile);
47+
updateDeclaredFunctions(declaredFunction);
48+
}
49+
}
50+
3751
// First child must be `Identifier`
3852
// examples of what gets skipped: `fs.readFile('lol.json')` or `ipc.on('something', () => {})`
3953
if (ts.isCallExpression(node)) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-call-graph",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Create a call graph of your TypeScript files",
55
"keywords": [
66
"TypeScript",

0 commit comments

Comments
 (0)