title: How do you use typed errors in async catch()
body: <p>I am using an <code>async</code> function to call an existing promise-based API which rejects the promise with a typed error. </p>
  
  <p>You could mock this behavior like this:</p>
  
  <pre><code>interface ApiError {
    code: number;
    error: string;
  }
  
  function api(): Promise&lt;any&gt; {
    return new Promise((resolve, reject) =&gt; {
      reject({ code: 123, error: "Error!" });
    });
  }
  </code></pre>
  
  <p>Now with promises, I can annotate the error type to <code>ApiError</code>:</p>
  
  <pre><code>api().catch((error: ApiError) =&gt; console.log(error.code, error.message))
  </code></pre>
  
  <p>But when using <code>async</code> if I try to annotate the error type in <code>try ... catch()</code>:</p>
  
  <pre><code>async function test() {
    try {
      return await api();
    } catch (error: ApiError) {
      console.log("error", error);
    }
  }
  </code></pre>
  
  <p>It compiles with error:</p>
  
  <blockquote>
    <p>Catch clause variable cannot have a type annotation.</p>
  </blockquote>
  
  <p>How, then, do I know what kind of error I'm expecting? Do I need to write an assertion in the <code>catch()</code> block? Is that a bug/incomplete feature of async?</p>