title: how do you declare a variable holds a generic delegate?
body: <p>without having to repeat the shape of the delegate in other files, how do I declare a reference to a function with a given known-by-typescript shape?</p>
  
  <p>function:</p>
  
  <pre><code>/**
   * @param {object} prev
   * @param {object} next
   * @param {string} name - the name of the child param of both objects to compare
   */
  exports.getModification = &lt;T&gt; (prev:T,next:T, name:string):Modification&lt;T&gt; =&gt;
  {
      const getIsChanging = p =&gt; prev[p] != null &amp;&amp; p in next &amp;&amp; next[p];
      const getIsAdding = p =&gt; !prev[p] &amp;&amp; p in next &amp;&amp; next[p];
      const getIsDeleting = p =&gt; prev[p] != null &amp;&amp; p in next &amp;&amp; !next[p];
      const result:Modification&lt;T&gt; = (
          getIsChanging(name) ? {changeType:'changing',next: next[name]}
          : getIsAdding(name)? {changeType:'adding', next: next[name]}
          : getIsDeleting(name) ? {changeType:'deleting',next:undefined}
          : {changeType:undefined,next:undefined});
      return result;
  };
  </code></pre>
  
  <p>I've tried to write the definition of the method/delegate via</p>
  
  <pre><code>interface Modification&lt;T&gt;{
      changeType: string | undefined;
      next: T | undefined;
  }
  interface GetModificationDelegate&lt;T&gt;{
      (prev:T,next:T, name:string) : Modification&lt;T&gt;;
  }
  // try a type alias
  type GetModificationFunction&lt;T&gt; = (prev:T,next:T, name:string) =&gt; Modification&lt;T&gt;;
  </code></pre>
  
  <p>both of these compile just fine. however, telling typescript a symbol is a reference to this fails.</p>
  
  <pre><code>var getModification = (app.getModification as GetModificationFunction&lt;T&gt;);
  var getModification: &lt;T&gt;GetModificationFunction&lt;T&gt; = app.getModification;
  var getModification: &lt;T extends{}&gt;GetModificationFunction&lt;T&gt; = app.getModification;
  </code></pre>
  
  <p>none of those compile. without resorting to classes (which I assume makes this simple) how can I simple tell typescript something is a generic delegate of a shape it already knows?</p>