title: How to run a function asynchronously in Typescript?
body: <p>I want to run my function asynchronously, but how do I do that?:</p>
  
  <pre><code>    checkLocation() {
          return __awaiter(this, void 0, Promise, function* () {
              while (true) {
                  setTimeout(function () {
                      this.diagnostic.isLocationEnabled().then(
                          (isAvailable) =&gt; {
                              console.log('Is available? ' + isAvailable);
                              if (!isAvailable) {
                                  alert('Please turn on the location service');
                              }
                          }).catch((e) =&gt; {
                              console.log(e);
                          });
                  }, 5000)
              }
          });
      }
  }
  </code></pre>
  
  <p>One of the discovered problems is that TS cannot fine name <code>__awaiter</code>. I have tried to follow <a href="https://blogs.msdn.microsoft.com/typescript/2015/11/03/what-about-asyncawait/" rel="nofollow noreferrer">this</a> </p>