title: How to convert typescript async/await code as it is to javascript code
body: <p>I am exploring hap17 async/await. My code is working fine but I am curious why it is converting ts code in different format. Means If I do not set <code>"module": "commonjs"</code> in tsconfig file then, after tsc it generate js code which convert await to _awaiter with switch case. If I set <code>"module": "commonjs"</code> then it convert await to yield. Why it is so?
  And what if I want to convert same await in js file. Then what should be the configuration? </p>
  
  <p>My tsconfig file is like</p>
  
  <pre><code>`{
      "compilerOptions": {
          "outDir": "build",
          "sourceMap": true,
          "allowJs": true,
          "target": "es6",
          "removeComments": false,
          "noImplicitAny": false,
          "module": "commonjs",
      },
      "include": [
          "web/*.ts"
      ],
      "exclude": [
          "node_modules",
          "**/*.spec.ts"
      ]
  }`
  </code></pre>
  
  <p>Ts file code</p>
  
  <pre><code>var server = new Hapi.Server({
    listener: http2.createServer(),
    host: 'localhost',
    port: 3000,
    tls: true,
  })
  
  const init = async () =&gt; {
      try {
        await server.register({register: routes, name: "test"})
        await server.start();
        console.log(`Server running at: ${server.info.uri}`);
      } catch (err) {
        console.log(err);
      }
  };
  
  init();
  </code></pre>
  
  <p>when I do <code>tsc</code> I am expecting same code in js file also ie async/await.
  But it convert async await to following format</p>
  
  <pre><code>const init = () =&gt; tslib_1.__awaiter(this, void 0, void 0, function* () {
      try {
          yield server.register({ register: base_route_1.default, name: "test" });
          yield server.start();
          console.log(`Server running at: ${server.info.uri}`);
      }
      catch (err) {
          console.log(err);
      }
  });
  init();
  </code></pre>