Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 69655fc

Browse files
committed
fix: don't hoisting defineProps type arg without experimentalRfc436
close #1994
1 parent 485a670 commit 69655fc

File tree

1 file changed

+10
-3
lines changed
  • vue-language-tools/vue-language-core/src/generators

1 file changed

+10
-3
lines changed

vue-language-tools/vue-language-core/src/generators/script.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ export function generate(
263263
codeGen.push(`>`);
264264
}
265265
codeGen.push('(');
266-
if (scriptSetupRanges.propsTypeArg) {
266+
if (vueCompilerOptions.experimentalRfc436 && scriptSetupRanges.propsTypeArg) {
267267
codeGen.push('__VLS_props: ');
268268
addVirtualCode('scriptSetup', scriptSetupRanges.propsTypeArg.start, scriptSetupRanges.propsTypeArg.end);
269269
}
270270
codeGen.push(') => {\n');
271271
codeGen.push('const __VLS_setup = async () => {\n');
272-
if (scriptSetupRanges.propsTypeArg) {
272+
if (vueCompilerOptions.experimentalRfc436 && scriptSetupRanges.propsTypeArg) {
273273
addVirtualCode('scriptSetup', scriptSetupRanges.importSectionEndOffset, scriptSetupRanges.propsTypeArg.start);
274274
codeGen.push('typeof __VLS_props');
275275
addVirtualCode('scriptSetup', scriptSetupRanges.propsTypeArg.end);
@@ -308,7 +308,14 @@ export function generate(
308308
codeGen.push(`__VLS_WithDefaults<`);
309309
}
310310

311-
codeGen.push(`__VLS_TypePropsToRuntimeProps<typeof __VLS_props>`);
311+
codeGen.push(`__VLS_TypePropsToRuntimeProps<`);
312+
if (vueCompilerOptions.experimentalRfc436) {
313+
codeGen.push(`typeof __VLS_props`);
314+
}
315+
else {
316+
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.propsTypeArg.start, scriptSetupRanges.propsTypeArg.end);
317+
}
318+
codeGen.push(`>`);
312319

313320
if (scriptSetupRanges.withDefaultsArg) {
314321
codeGen.push(`, typeof __VLS_withDefaultsArg`);

0 commit comments

Comments
 (0)