title: Is it possible to implement a function interface in TypeScript?
body: <p>I would like to be able to do this</p>
  
  <pre><code>class MyFunc extends ((s: string) =&gt; boolean) { ... }
  </code></pre>
  
  <p>so that an instance of <code>MyFunc</code> can be used as a function which takes a string as input and returns a boolean as follows:</p>
  
  <pre><code>const f = new MyFunc();
  const b: boolean = f('someString');
  </code></pre>
  
  <p>Is this possible in TypeScript?</p>
  
  <p>In languages such as Scala, one can extend the type <code>String =&gt; Boolean</code>, and provide an <code>apply</code> method to achieve this.</p>
  
  <pre><code>class MyFunc extends (String =&gt; Boolean)
  val f = new MyFunc()
  val b: Boolean = f("someString")
  </code></pre>