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 is not a constructor function type #83

Closed
kdheepak opened this issue Jun 13, 2021 · 5 comments
Closed

vue is not a constructor function type #83

kdheepak opened this issue Jun 13, 2021 · 5 comments

Comments

@kdheepak
Copy link

Hi, I'm getting an error when I try to use this in my Vue 3 project. The error is in the description section of this issue.

Are you sure this multiselect component works in Vue 3? From this blog post (https://labs.thisdot.co/blog/your-first-vue-3-app-using-typescript), it appears something like this might be necessary in a shim-vue.d.ts file:

declare module "*.vue" {
  import { defineComponent } from "vue";
  const component: ReturnType<typeof defineComponent>;
  export default component;
}

I'm new to Vue so I'm not really sure what is going on here.

Version

  • Vue version: 3

Description

node_modules/@vueform/multiselect/src/Multiselect.d.ts:3:35 - error TS2507: Type 'typeof import("{myproject}/node_modules/vue/dist/vue")' is not a constructor function type.

3 declare class Multiselect extends Vue {
                                    ~~~

Demo

I'm unable to use the JSFiddle template to reproduce the bug because I don't know how to get multiselect installed in that template.

@kdheepak
Copy link
Author

I'm not sure where the problem is exactly but removing vue-tsc --noEmit && from the npm run build script doesn't cause this issue anymore.

────┐
13: │
────┘
 12 ⋮ 13 │    "vue-tsc": "^0.0.24"
 13 ⋮ 14 │  },
 14 ⋮ 15 │  "scripts": {
-15 ⋮    │    "build": "vue-tsc --noEmit && vite build",
+   ⋮ 16 │    "build": "vite build",
 16 ⋮ 17 │    "dev": "vite",
 17 ⋮ 18 │    "serve": "vite preview"
 18 ⋮ 19 │  },

@daniele-bolla
Copy link

I am having the same problem. Could it be reopened?
Removing vue-tsc --noEmit && is not a real fix.

@cyberillithid
Copy link

In case if you're wondering: vue-tsc could be satisfied with an edit of first lines of Multiselect.d.ts to the following effect:

import Vue, { VNode, defineComponent } from 'vue';

declare class Multiselect implements ReturnType<typeof defineComponent> {
// ... 

Since I have no idea how that would affect Vue 2 support, that's probably not something worth a pull-request, though.

@otezz
Copy link

otezz commented Jan 14, 2022

Hi @adamberecz, could you please take a look at solution from @cyberillithid?

I can't build my project and removing vue-tsc is not an option

@dadebue
Copy link

dadebue commented Feb 18, 2022

@otezz I had the same problem while using the multiselect in my Typescript Vue3 project. Removing vue-tsc --noEmit && was not an option.
So I forked the repo and added the solution from @cyberillithid.

At first the build was not possible because of node-sass. So I switched to sass and now everything is working...

@adamberecz would that be a possibility for your repo aswell?

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

6 participants