[Vuejs]-How to set type for createApp(App) function in vuejs 3?

10👍

✅

createApp returns an App instance. Since you already have an App imported, you need to rename the type while importing. But notice app.mount returns a different type, you can’t chain it after createApp without changing the type:

import { createApp, App as Application } from 'vue'
import App from './App.vue'
// other imports

let app: Application 

auth.onAuthStateChanged(() => {
  if (!app) {
    app = createApp(App)
    app.use(store)
    app.use(router)
    app.mount('#app')
  }
})

Leave a comment