title: Get AsyncFunction constructor in Typescript
body: <p>So I'm trying to dynamically create AsyncFunctions in a Typescript Program. <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction" rel="nofollow noreferrer">MDN</a> says that I can get the AsyncFunction constructor by </p>
  
  <pre><code>var AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
  </code></pre>
  
  <p>but typescript compiles this to</p>
  
  <pre><code>var AsyncFunction = Object.getPrototypeOf(function () {
      return __awaiter(this, void 0, void 0, function* () { });
  }).constructor;
  </code></pre>
  
  <p>The difference can be seen by simply attempting to use the constructor;</p>
  
  <pre><code>new AsyncFunction("return 1;")();
  </code></pre>
  
  <p>returns a Promise (what I need) when run in Firefox, but simply returns a <code>1</code>when run after being passed through typescript.</p>
  
  <p>How can I stop Typescript from mangling my async functions?</p>