title: Parse TypeScript to generate simple call graph
body: <p>I'm not really sure where to begin so I'm looking for some pointers for <strong>how to get started</strong>. If this isn't the right place for this type of question just let me know thanks ^^</p>
  
  <p>I want to visualize the call list in <a href="https://swimlanes.io/" rel="nofollow noreferrer">swimlanes.io</a> so I think a parser will help me to automate this process:</p>
  
  <p>example input:</p>
  
  <pre><code>const removeKey = (key: string, { [key]: _, ...rest }: any) =&gt; rest;
  
  export const expandedOutput = (array: any[]) =&gt; {
    return array.reduce(function(r, o, i) {
      Object.keys(o).forEach(function(k) {
        r[k] = r[k] || [];
        r[k][i] = o[k];
      });
      return r;
    }, {});
  };
  
  export const previewQuery = (table: string, lines: number) =&gt; `
  select * from ${table} limit ${lines};
  `;
  
  const id = 'test';
  
  const [preview] = await bigquery.query(previewQuery(id, 3));
  
  console.table(removeKey('created_at', expandedOutput(preview)));
  </code></pre>
  
  <p>desired output: </p>
  
  <p>( <a href="https://swimlanes.io/d/JXXXMC0YF" rel="nofollow noreferrer">https://swimlanes.io/d/JXXXMC0YF</a> )</p>
  
  <pre><code>previewQuery -&gt; previewQuery: table: string
  note:
  'test'
  
  previewQuery -&gt; previewQuery: lines: number
  note:
  3
  
  previewQuery -&gt; bigquery.query: query: string
  note: 
  =&gt; \`
  select * from ${table} limit ${lines};
  \`
  
  bigquery.query -&gt; [preview]: PagedResponse&lt;any, Query, bigquery.ITableDataList&gt;
  
  [preview] -&gt; expandedOutput: array: any[]
  
  removeKey -&gt; removeKey: key: string
  note:
  'created_at'
  
  expandedOutput -&gt; removeKey: { [key]: _, ...rest }: any
  note:
  =&gt; {
    return array.reduce(function(r, o, i) {
      Object.keys(o).forEach(function(k) {
        r[k] = r[k] || [];
        r[k][i] = o[k];
      });
      return r;
    }, {});
  }
  
  removeKey -&gt; console.table: (key: string, { [key]: _, ...rest }: any)
  note:
  =&gt; rest
  </code></pre>
  
  <p>I'm surprised there isn't already a tool like this but maybe I'm way in over my head... </p>
  
  <ol>
  <li><p>I'd like to be able to parse one typescript file but also include all the called functions from other modules. Do I need to write something that looks like "tree shaking" ??</p></li>
  <li><p>I'm not sure what to do about function internals like the expandedOutput() in my example... For me, the point of this whole process is mostly about seeing the connection between functions so I'm not so concerned about function internals. It's fine to just ignore them</p></li>
  <li><p>It would be cool if I could figure out how to read the implicit types or types in <code>*.ts.d</code> declaration files like how VS Code was able to pull out "PagedResponse" in my example... how much work do you think this would be? Maybe it would be easier if I only included explicit types</p></li>
  </ol>
  
  <p>hmmm maybe I can use <code>typescript-estree</code></p>