Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 2.7.0-beta.4 new Vue(...) return type becomes never when using setup() in the root instance #12568

Closed
danielwaltz opened this issue Jun 21, 2022 · 0 comments

Comments

@danielwaltz
Copy link

danielwaltz commented Jun 21, 2022

Version

2.7.0-beta.4

Reproduction link

github.com

Steps to reproduce

After initializing a new Vue 2.7 project using the new Vite Vue 2 plugin with Volar take-over mode enabled, defining a setup() function in the root Vue instance changes the return type to never, leading to calling .$mount('#app') displaying a type error both in VSCode and when running vue-tsc.

new Vue({
  router,
  render: (h) => h(App)
  // No issues
}).$mount('#app');
new Vue({
  router,
  setup() {
    provide('test', 'value');
  },
  render: (h) => h(App)
  // Property '$mount' does not exist on type 'never'.
}).$mount('#app');

Happening both under TypeScript version 4.6.4 and 4.7.4.

What is expected?

Defining a setup function in the root instance works without changing the return type to never.

What is actually happening?

Using setup in the root displays a type error when trying to call $mount().


I believe everything is working fine in runtime, purely a TypeScript issue from what I can tell.

EDIT: Some additional info, I found that returning an empty object can work around this issue:

new Vue({
  router,
  setup() {
    provide('test', 'value');
    return {};
  },
  render: (h) => h(App)
  // No issues
}).$mount('#app');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant