title: TypeScript: Function as object key
body: <p>For sane reasons, I need to have an object that has functions as key in an object, e.g:</p>
  
  <pre><code>function a() {}
  function b() {}
  
  const obj = {
    [a]: b
  }
  </code></pre>
  
  <p>The reason for this is that I want to map the values of function <code>a</code> to function <code>b</code> and be able to remember and remove mappings again.</p>
  
  <p>Now I wonder how to write typings for this in TypeScript. If I do</p>
  
  <pre><code>type MapFunctions = { [key: Function]: Function };
  </code></pre>
  
  <p>I will get the error </p>
  
  <blockquote>
  <pre><code>An index signature parameter type must be 'string' or 'number'.ts(1023)
  </code></pre>
  </blockquote>
  
  <p>But how would I write a type for this?</p>