Skip to content

Invalid types to pass slots to parent #282

@negezor

Description

@negezor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    tsTypescript related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions