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

Invalid types to pass slots to parent #282

Closed
negezor opened this issue Nov 10, 2022 · 2 comments
Closed

Invalid types to pass slots to parent #282

negezor opened this issue Nov 10, 2022 · 2 comments
Labels
ts Typescript related issue

Comments

@negezor
Copy link

negezor commented Nov 10, 2022

Version

  • Vue version: 3
  • Multiselect: 2.5.6

Description

When trying to use pass slots up, a type error appears.

<template v-for="(_, slot) in $slots" #[slot]="scope">
  <slot v-bind="scope" :name="slot" />
</template>
src/App.vue:7:44 - error TS7053: Element implicitly has an 'any' type because expression of type 'string | number' can't be used to index type '{ placeholder: any; afterlist: any; beforelist: any; list: any; multiplelabel: any; singlelabel: any; option: any; groupLabel: any; tag: any; infinite: any; }'.
  No index signature with a parameter of type 'string' was found on type '{ placeholder: any; afterlist: any; beforelist: any; list: any; multiplelabel: any; singlelabel: any; option: any; groupLabel: any; tag: any; infinite: any; }'.

                 #[slot]="scope"

Demo

Run: npm run build

https://codesandbox.io/s/pedantic-sky-hb7dqe?file=/src/App.vue

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

xibman commented Feb 17, 2023

Possible workaround

<Multiselect v-bind="$attrs" :name="name">
    <template v-for="(_, slot) in ($slots as unknown as Multiselect['$slots'])" #[slot]="scope">
        <slot :name="slot" v-bind="scope || {}" />
    </template>
</Multiselect>

@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!

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

No branches or pull requests

3 participants