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

Property 'select' does not exist on type 'Multiselect' #287

Closed
cnakh opened this issue Nov 23, 2022 · 8 comments
Closed

Property 'select' does not exist on type 'Multiselect' #287

cnakh opened this issue Nov 23, 2022 · 8 comments
Labels
ts Typescript related issue upcoming

Comments

@cnakh
Copy link

cnakh commented Nov 23, 2022

I use with Vue 3 with TypeScript as code below

<template>
    <Multiselect
          valueProp="id"
          label="name"
          :options="getCategories"
          :searchable="true"
          ref="selectCategory"
    />
</template>

<script setup lang="ts">
import Multiselect from "@vueform/multiselect";
...
const selectCategory = ref<InstanceType<typeof Multiselect>>();
...
</script>

When I call select method it work fine in development, but when I build it get error

selectCategory.value.select(data);
Property 'select' does not exist on type 'Multiselect'.
@n14s
Copy link

n14s commented Dec 10, 2022

I'm also interested to know how to use the API with Vue3 composition API and script setup

@adamberecz adamberecz added the ts Typescript related issue label Dec 21, 2022
@antpngl92
Copy link

antpngl92 commented Mar 8, 2023

I had a similar error trying to access selectCategory.value.isOpen boolean.

To fix that I created a mock ref type:

type MultiselectRef = InstanceType<typeof Multiselect> & {
  isOpen: boolean;
}

in your case will be

type MultiselectRef = InstanceType<typeof Multiselect> & {
  select: (data: object | string | whatever) => void;
}

@adamberecz Perhaps a type definition with all attributes of the ref object would fix further similar issues?

@adamberecz
Copy link
Collaborator

Could anyone reliably help me with TS issues to put everything in place once and for all in both Vue 2 & 3? If so, please let me know!

@antpngl92
Copy link

Could anyone reliably help me with TS issues to put everything in place once and for all in both Vue 2 & 3? If so, please let me know!

I can do it, will open a PR at some point today.

@abaumg abaumg mentioned this issue Apr 6, 2023
@tholu
Copy link

tholu commented May 12, 2023

@antpngl92 Thanks for your PR! @adamberecz Can this be merged anytime soon?

Edit: I have referenced the wrong component, works now.

@crobinson-expl
Copy link

This PR fixes an issue I'm having with TypeScript and the open API method. @adamberecz, what is preventing the PR from being approved and merged?

@adamberecz
Copy link
Collaborator

This should now be fixed in 2.6.3. Let me know if you still encounter any issues. Thanks for the patience. 🙏

@crobinson-expl
Copy link

This should now be fixed in 2.6.3. Let me know if you still encounter any issues. Thanks for the patience. 🙏

Thanks, @adamberecz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ts Typescript related issue upcoming
Projects
None yet
Development

No branches or pull requests

6 participants