`SlotsType<{ default: T }>` does not type in `defineComponent` "Functional Signature" mode
Vue version
3.3.8
Link to minimal reproduction
Steps to reproduce
Define a component like this:
<script lang="ts">
import { SetupContext, SlotsType, defineComponent } from "vue";
export default defineComponent(
<T,>(
props: { msg: T; list: T[] },
ctx: SetupContext<{}, SlotsType<{ default: T }>>,
) =>
() =>
ctx.slots.default?.(props.msg) ?? null,
{ props: ["msg", "list"] as never[] },
);
</script>
What is expected?
No errors, because SlotType<{ name: type }>
is accepted syntax
What is actually happening?
No overload matches this call.
Overload 1 of 5, '(setup: (props: { msg: T; list: T[]; }, ctx: { attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: (exposed?: Record<string, any>) => void; }) => RenderFunction | Promise<...>, options?: Pick<...> & { ...; }): <T>(props: { ...; } & {}) => any', gave the following error.
Overload 2 of 5, '(setup: (props: unknown[], ctx: { attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: (exposed?: Record<string, any>) => void; }) => RenderFunction | Promise<...>, options?: Pick<...> & { ...; }): (props: unknown[] & {}) => any', gave the following error.ts(2769)
CompSlotObject.vue(7, 39): 'default' is declared here.
CompSlotObject.vue(5, 3): Did you mean to call this expression?
CompSlotObject.vue(5, 3): Did you mean to call this expression?
System Info
No response
Any additional comments?
Replacing SlotsType<{ default: T }>
with SlotsType<{ default?(msg: T): any }>
works.
BTW, even in fixed version type of slot props in App.vue
is any
. Is this a vuejs/core issue, or vuejs/language-tools?
Using the SlotsType Helper here in this makes not sense, and it's not what it's been documented to be used for.
https://vuejs.org/api/options-rendering.html#slots
The ctx.slots object is an object containing slot functions, so typecasting it to something else makes no sense. Annotate it as what it is - an object containing functions.