Slots defined with `SlotsType` in "Functional Signature" `defineComponent` do not get a type
Vue version
3.3.8
Link to minimal reproduction
Steps to reproduce
I have defined a component with functional defineComponent
signature and assigned some slots.
<script setup lang="ts">
import { SetupContext, SlotsType, defineComponent, h } from "vue";
const Comp = defineComponent(
(
_1: {},
_2: SetupContext<
{},
SlotsType<{ default?(data: { foo: string; bar: number }): any }>
>,
) =>
() =>
null,
{
slots: Object as SlotsType<{ default: { foo: string; bar: number } }>,
}
);
h(
Comp,
null,
{
default: (data) => null,
// ^? (parameter) data: any
}
);
</script>
<template>
<Comp v-slot="data"></Comp>
<!-- when hovering over `data` it says `data: any` -->
</template>
What is expected?
I would have expected the type of slot prop to be set.
What is actually happening?
Type of slot prop is any
, both in h
and in <template>
System Info
No response
Any additional comments?
When using regular defineComponent
signature by removing the first argument, prop type appears in <template>
but not in h
.
This is caused because Functional components are very barebones, basically what we return is the function with props.
One issue sort of related https://github.com/microsoft/TypeScript/issues/14729, since it would be nice to also add some typing for using in JSX