title: A Typed array of functions
body: <p>I'm struggling to figure out if it's possible in TypeScript to declare a statically typed array of functions.</p>
  
  <p>For example, I can do this:</p>
  
  <pre><code>foo: (data:string) =&gt; void = function (data) {};
  </code></pre>
  
  <p>But if I want foo to be an array of functions that take a string and return nothing, how do I do that?</p>
  
  <pre><code>foo: (data:string) =&gt; void [] = [];
  </code></pre>
  
  <p>Doesn't work because TypeScript thinks it's a function that takes a string and returns an array of void, and it doesn't seem to like me trying to wrap the function in brackets.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>Answer</strong>: Thanks to mohamed below, here's an example that works in the TypeScript Playground:</p>
  
  <pre><code>class whatever {
  public foo: { (data: string): void; }[] = [];
  
      dofoo() {
          for (var i=0; i &lt; this.foo.length; i++) {
               this.foo[i]("test");
          }
      }
  }
  
  var d = new whatever();
  
  d.foo.push(function(bar){alert(bar)})
  d.foo.push(function(bar){alert(bar.length.toString())})
  
  d.dofoo();
  </code></pre>