title: Why Javascript bind returns any?
body: <p>In the following code, the bind method has been called so that <code>this.flavour</code> does not become <code>undefined</code> when <code>bake</code> is called from another class.</p>
  
  <pre><code>interface CakeEvent{
      onBake(flour:number):void
  }
  class Cake {
      private listener: CakeEvent
      addChocolate(listener: CakeEvent) {
          this.listener = listener
      }
  
      onBake(flour: number) {
          this.listener.onBake(flour)
      }
  
  
  
  }
  class Chocolate {
      private flavour = 'vanilla'
      private bake(flour:number) {
          console.log(this.flavour, flour)
      }
      constructor(private cake: Cake) {
          const listener: CakeEvent = {
              onBake: this.bake.bind(this) // &lt;- Here
          }
          this.cake.addChocolate(listener)
  
      }
  }
  const cake = new Cake()
  const choco = new Chocolate(cake)
  cake.onBake(4564)
  </code></pre>
  
  <p>However, as soon as the method bind is called on the function bake, this type becomes <code>any</code>. This means that Typescript will not throw a compilation error if its property does not match the interface definition <code>CakeEvent</code>. If it becomes <code>any</code>, the interface <code>CakeEvent</code> is a useless waste of time.</p>
  
  <p>What is the motivation behind returning any? shouldn't it return the same type of function?</p>
  
  <p>Currently, what is the workaround to prevent this to become any?</p>
  
  <p>from <code>node_modules/typescript/lib.es5.d.ts</code></p>
  
  <pre><code>/**
   * For a given function, creates a bound function that has the same body as the original function.
   * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
   * @param thisArg An object to which the this keyword can refer inside the new function.
   * @param argArray A list of arguments to be passed to the new function.
   */
  bind(this: Function, thisArg: any, ...argArray: any[]): any;
  </code></pre>