title: Middy with TypeScript, callback type
body: <p>I'm trying to use TyepScript witn <code>Middy</code> on a Lambda API call.
  Part of my code:</p>
  <pre><code>// My types definition
  import BodyRequestType from 'types';
  
  // some code
  
  async function myFunction (
    event: { body: BodyRequestType },
    callback: ??? &lt;--
  ): Promise&lt;void&gt; {
    // my code
    return callback(null, {
      statusCode: 200,
      body: JSON.stringify(data)
    });
  }
  
  export const handler = middy(myFunction);
  </code></pre>
  <p>I tried to use:</p>
  <pre><code>import { Callback } from 'aws-lambda'
  // then...
  callback: Callback
  </code></pre>
  <p>But I get this error on <code>middy(myFunction)</code>:</p>
  <pre><code>TS2345: Argument of type '(event: { body: BodyRequestType; }, callback: Callback&lt;any&gt;) =&gt; Promise&lt;void&gt;' is not assignable to 
  parameter of type 'AsyncHandler&lt;Context&gt;'.
  Type '(event: { body: BodyRequestType; }, callback: Callback&lt;any&gt;) =&gt; Promise&lt;void&gt;'
  is not assignable to type '(event: any, context: Context, callback: Callback&lt;any&gt;) =&gt; void'.
  Types of parameters 'callback'and 'context' are incompatible.
  Type 'Context' is not assignable to type 'Callback&lt;any&gt;'.
  Type 'Context' provides no match for the signature '(error?: string | Error | null | undefined, result?: any): void'.
  </code></pre>
  <p>What type should I use on <code>callback</code> argument of myFunction?</p>