Passing all slots to child component causes TypeScript errors #2586
-
I'm quite new to Vue and TypeScript but I have a need to wrap a component and pass down all the slots to a child component. This is a snippet of what I came up with: Wrapper component: <template>
<Child v-bind="$attrs">
<template
v-for="(name, index) of Object.keys($slots)"
#[name]="slotData"
:key="index"
>
<slot :name="name" v-bind="slotData || {}"></slot>
</template>
</Child>
</template>
<script setup lang="ts">
import Child from '@/components/Child.vue'
</script>
<script lang="ts">
export default {
inheritAttrs: false
}
</script> Child component: <template>
<div>
<slot name="foo"></slot>
<slot name="bar"></slot>
</div>
</template> Type checking this results in the following errors:
It complains that Any ideas how to properly type this, or is this limitations with the tools? I've created a repository that shows the problem: https://github.com/jacob-carlborg-apoex/vue-wrapper-component-ts. Clone the repository and run |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Thanks for the repro case, fixed by d35ed09. |
Beta Was this translation helpful? Give feedback.
Thanks for the repro case, fixed by d35ed09.