title: Typescript expects undefined to be returned from helper function in d3.nest().rollup()
body: <p>I am currently building a visualization in D3 (v4.4.0) and Typsecript, having the typings installed from @types/d3. For the visualization I need to nest my data. This I am trying to do with this snippet, that should count the number of entries per key:</p>
  
  <pre><code>d3.nest()
    .key(function(d: any) {return d.key;})
    .rollup(function(leaves: any){
      return d3.sum(leaves, function (d) {
        return 1;
      })
    })
    .entries(this.data);
  </code></pre>
  
  <p>For the helper function in the rollup method I get a type error:</p>
  
  <pre><code>severity: 'Error'
  message: 'Argument of type '(leaves: any) =&gt; number' is not assignable to parameter of type '(values: {}[]) =&gt; undefined'.
  Type 'number' is not assignable to type 'undefined'.'
  at: '46,15'
  source: 'ts'
  </code></pre>
  
  <p>So it seems tsc expects rollup() to return undefined, which does not make sense to me and this code worked fine in pure javascript. Just nesting the data without the rollup() also works.</p>
  
  <p>Does anybody know what could have gone wrong here?</p>
  
  <p>Thanks,
  Thomas</p>