Skip to content

Commit 860ffca

Browse files
authored
fix(language-core): prevent eager inference of slot props from generics (#5247)
1 parent 03a6d52 commit 860ffca

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/language-core/lib/codegen/globalTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export function generateGlobalTypes({
158158
: (_: {}${checkUnknownProps ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${checkUnknownProps ? '' : ' & Record<string, unknown>'} } };
159159
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
160160
function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownComponents ? '' : ' & Record<string, unknown>'}) => void;
161-
function __VLS_asFunctionalSlot<S>(slot: S): (props: NonNullable<S> extends (props: infer P) => any ? P : {}) => void;
161+
function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
162162
function __VLS_tryAsConstant<const T>(t: T): T;
163163
}
164164
`;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script setup lang="ts" generic="T extends string">
2+
defineSlots<{
3+
[K in `slot:${T}`]?: () => any;
4+
}>();
5+
6+
let slots!: T[];
7+
</script>
8+
9+
<template>
10+
<div v-for="slot of slots">
11+
<slot :name="`slot:${slot}`"></slot>
12+
</div>
13+
</template>

0 commit comments

Comments
 (0)