title: async/await and promise in TypeScript
body: <p>I am trying to understand why the return type <code>string</code> in the following method is underlined red as error:</p>
  <pre><code>exportPageAsText(pageNumber: number): string {
          (async () =&gt; {
              const text = await this.pdfViewerService.getPageAsText(pageNumber);
              console.log(text);
              return text;
          })();
  }
  </code></pre>
  <p>The error message reads: <code>A function whose declared type is neither 'void' nor 'any' must return a value.</code> so I moved <code>return text;</code> out of the <code>async</code> scope and placed it after <code>})();</code> but that made the <code>text</code> variable unrecognizable.</p>
  <p>Then I thought maybe it's because the method return type should be a <code>Promise</code> so I changed the signature to:</p>
  <pre><code>exportPageAsText(pageNumber: number): Promise&lt;string&gt;
  </code></pre>
  <p>But I get a new error saying that <code>A function whose declared type is neither 'void' nor 'any' must return a value.</code></p>
  <p>Can someone please help me understand what I am doing wrong?</p>