Skip to content

Commit cb72c6f

Browse files
committed
fix: only generate jsx slot props into __VLS_PublicProps
1 parent e1bbf75 commit cb72c6f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type __VLS_WithDefaultsLocal<P, D> = {
2727
type __VLS_WithSlots<T, S> = T & {
2828
new(): {
2929
${getSlotsPropertyName(vueCompilerOptions.target)}: S;
30-
${vueCompilerOptions.jsxSlots ? `$props: ${PropsChildren.name}<S>;` : ''}
3130
}
3231
};
3332
`.trimStart(),

packages/language-core/lib/codegen/script/scriptSetup.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,21 @@ function* generateSetupFunction(
318318
yield* generateScriptSectionPartiallyEnding(scriptSetup.name, scriptSetup.content.length, '#3632/scriptSetup.vue');
319319
yield* generateMacros(options, ctx);
320320

321-
yield* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges);
321+
const hasSlots = !!(
322+
scriptSetupRanges.defineSlots
323+
|| options.templateCodegen?.slots.length
324+
|| options.templateCodegen?.dynamicSlots.length
325+
);
326+
327+
yield* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges, hasSlots);
322328
yield* generateModelEmit(scriptSetup, scriptSetupRanges);
323329
yield* generateTemplate(options, ctx);
324330

325331
if (syntax) {
326332
const prefix = syntax === 'return'
327333
? [`return `]
328334
: generateConstExport(scriptSetup);
329-
if (
330-
scriptSetupRanges.defineSlots
331-
|| options.templateCodegen?.slots.length
332-
|| options.templateCodegen?.dynamicSlots.length
333-
) {
335+
if (hasSlots) {
334336
yield `const __VLS_base = `;
335337
yield* generateComponent(options, ctx, scriptSetup, scriptSetupRanges);
336338
yield endOfLine;
@@ -439,6 +441,7 @@ function* generateComponentProps(
439441
ctx: ScriptCodegenContext,
440442
scriptSetup: NonNullable<Sfc['scriptSetup']>,
441443
scriptSetupRanges: ScriptSetupRanges,
444+
hasSlots: boolean,
442445
): Generator<Code> {
443446
if (scriptSetupRanges.defineProps?.typeArg && scriptSetupRanges.withDefaults?.arg) {
444447
yield `const __VLS_defaults = `;
@@ -467,7 +470,7 @@ function* generateComponentProps(
467470
}
468471

469472
const propTypes: string[] = [];
470-
if (scriptSetupRanges.defineSlots && options.vueCompilerOptions.jsxSlots) {
473+
if (options.vueCompilerOptions.jsxSlots && hasSlots) {
471474
propTypes.push(`${ctx.localTypes.PropsChildren}<__VLS_Slots>`);
472475
}
473476
if (scriptSetupRanges.defineProps?.typeArg) {

0 commit comments

Comments
 (0)