Skip to content

Commit fa809a6

Browse files
committed
fix: runtime props for generic component
1 parent bb67336 commit fa809a6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ export function generateGlobalTypes(options: VueCompilerOptions) {
144144
type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;
145145
type __VLS_ProxyRefs<T> = import('${lib}').ShallowUnwrapRef<T>;
146146
147+
function __VLS_definePublicProps<T>(options: T): import('${lib}').${
148+
target >= 3.3 ? `ExtractPublicPropTypes` : `ExtractPropTypes`
149+
}<T>;
147150
function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
148151
item: T extends number ? number
149152
: T extends string ? string

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ export function* generateScriptSetup(
5959
if (ctx.generatedPropsType) {
6060
propTypes.push(`__VLS_PublicProps`);
6161
}
62+
if (scriptSetupRanges.defineProps?.arg) {
63+
yield `const __VLS_publicProps = __VLS_definePublicProps(`;
64+
yield generateSfcBlockSection(
65+
scriptSetup,
66+
scriptSetupRanges.defineProps.arg.start,
67+
scriptSetupRanges.defineProps.arg.end,
68+
codeFeatures.navigation,
69+
);
70+
yield `)${endOfLine}`;
71+
propTypes.push(`typeof __VLS_publicProps`);
72+
}
6273
if (scriptSetupRanges.defineEmits || scriptSetupRanges.defineModel.length) {
6374
propTypes.push(`__VLS_EmitProps`);
6475
}

0 commit comments

Comments
 (0)