title: How can I use async/await in the Vue 3.0 setup() function using Typescript
body: <p>(This question has been answered for JavaScript, see below, but this question is specific for TypeScript, which behaves differently)</p>
  <p>I'm trying to use async functionality in Vue3.0 using typescript.</p>
  <p>Without <strong>async</strong> this code works nice:</p>
  <pre><code>// file: components/HelloWorld.vue
  
  &lt;template&gt;
    &lt;div class=&quot;hello&quot;&gt;
      &lt;h1&gt;{{ msg }}&lt;/h1&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script lang=&quot;ts&quot;&gt;
  import {defineComponent} from 'vue'
  
  export default defineComponent({
    name: 'HelloWorld',
    props: {
      msg: String,
    },
    async setup() { // &lt;-- this works without 'async'
      const test = 'test'
  
      // await doSomethingAsynchronous()
  
      return {
        test,
      }
    },
  })
  &lt;/script&gt;
  </code></pre>
  <p>With <code>async setup()</code> the component &quot;HelloWorld&quot; disappears from the page, and the Firefox console tells me</p>
  <pre><code>&quot;Uncaught (in promise) TypeError: node is null (runtime-dom.esm-bundler.js)&quot;
  </code></pre>
  <p>When I change <code>async setup()</code> to <code>setup()</code>, the code works,
  but then I would not be able to use async/await inside the setup function.</p>
  <p>So my question:
  how do I use async/await inside the setup() function using Typescript?</p>
  <p><strong>EDIT:</strong></p>
  <p>The answer to this question: <a href="https://stackoverflow.com/questions/64009348/why-i-got-blank-when-use-async-setup-in-vue3">why i got blank when use async setup() in Vue3</a> shows that <code>async setup()</code> does work with JavaScript, so I would expect it to work in TypeScript as well.</p>