title: Defining TypeScript callback type
body: <p>I've got the following class in TypeScript:</p>
  
  <pre><code>class CallbackTest
  {
      public myCallback;
  
      public doWork(): void
      {
          //doing some work...
          this.myCallback(); //calling callback
      }
  }
  </code></pre>
  
  <p>I am using the class like this:</p>
  
  <pre><code>var test = new CallbackTest();
  test.myCallback = () =&gt; alert("done");
  test.doWork();
  </code></pre>
  
  <p>The code works, so it displays a messagebox as expected.</p>
  
  <p>My question is: Is there any type I can provide for my class field <code>myCallback</code>? Right now, the public field <code>myCallback</code> is of type <code>any</code> as shown above. How can I define the method signature of the callback? Or can I just set the type to some kind of callback-type? Or can I do nether of these? Do I have to use <code>any</code> (implicit/explicit)?</p>
  
  <p>I tried something like this, but it did not work (compile-time error):</p>
  
  <pre><code>public myCallback: ();
  // or:
  public myCallback: function;
  </code></pre>
  
  <p>I couldn't find any explanation to this online, so I hope you can help me.</p>