title: In Typescript how to promisify a function while binding with type safety?
body: <p>Consider the following promisification:</p>
  
  <pre><code>import { S3 } from 'aws-sdk'
  import { promisify } from 'util'
  
  const s3 = new S3({ apiVersion: '2006-03-01' })
  const getObject = promisify&lt;S3.GetObjectRequest, S3.GetObjectOutput&gt;(
    s3.getObject
  )
  </code></pre>
  
  <p>This works fine, except that you'll get errors like <code>TypeError: this.makeRequest is not a function</code> because <code>s3.getObject</code> is now bound to the wrong <code>this</code> scope. However, this:</p>
  
  <pre><code>const getObject = promisify&lt;S3.GetObjectRequest, S3.GetObjectOutput&gt;(
    s3.getObject.bind(s3)
  )
  </code></pre>
  
  <p>Destroys type safety and will error out: <code>Unsafe use of expression of type 'any'.</code> (assuming you use strict mode).</p>
  
  <p>So how can I promisify something like s3's <code>getObject</code> in Typescript?</p>