title: TypeScript type for nested arrays of functions
body: <p>I have a terrible data structure that is causing TypeScript to freak out.</p>
  <pre><code>let foo = {
      'baz':[
          [[x1, x2, x3], (a: any, b: number, c: number) =&gt; 5],
          [[x4], (a: number) =&gt; 7]],
      'bar':[
          [[], () =&gt; 0]]
  }
  </code></pre>
  <p><code>x1, x2...</code> are all <code>(s: string) =&gt; number | string</code> functions. I'm struggling to explicitly define <code>foo's</code> type. In Java-esque terms, it would be</p>
  <pre><code>Map&lt;String, List&lt;Tuple&lt;List&lt;Function&lt;String,Any&gt;&gt;, Function&lt;Any...,Integer&gt;&gt;&gt;&gt;
  </code></pre>
  <p>A list of lists, where the inner list has a list of functions and a function. As an aside, the number of elements in the list of functions will always equal the number of parameters in the anonymous function. The TypeScript compiler recommends:</p>
  <pre><code> Record&lt;string, (any[] | ((...args: any) =&gt; number))[][]&gt;
  </code></pre>
  <p>However, when I attempt to call <code>foo['baz'][0][0][2](myString)</code>, to call <code>x3(myString)</code>, the compiler yells</p>
  <pre><code>TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used 
  to index type 'any[] | ((...args: any) =&gt; number)'.   No index signature with a parameter of 
  type 'number' was found on type 'any[] | ((...args: any) =&gt; number)'.
  </code></pre>