diff --git a/packages/vue-language-core/src/generators/script.ts b/packages/vue-language-core/src/generators/script.ts index dd380ebc88..6fb04123a6 100644 --- a/packages/vue-language-core/src/generators/script.ts +++ b/packages/vue-language-core/src/generators/script.ts @@ -467,12 +467,11 @@ declare function defineProp(value?: T | (() => T), required?: boolean, rest?: let setupCodeModifies: [() => void, number, number][] = []; if (scriptSetupRanges.defineProps && !scriptSetupRanges.propsAssignName) { - if (scriptSetupRanges.withDefaults) { - setupCodeModifies.push([() => codes.push(`const __VLS_props = `), scriptSetupRanges.withDefaults.start, scriptSetupRanges.withDefaults.start]); - } - else { - setupCodeModifies.push([() => codes.push(`const __VLS_props = `), scriptSetupRanges.defineProps.start, scriptSetupRanges.defineProps.start]); - } + const ranges = scriptSetupRanges.withDefaults ?? scriptSetupRanges.defineProps; + codes.push(`const __VLS_props = `); + addVirtualCode('scriptSetup', ranges.start, ranges.end); + codes.push(`;\n`); + setupCodeModifies.push([() => codes.push(`__VLS_props`), ranges.start, ranges.end]); } if (scriptSetupRanges.defineSlots && !scriptSetupRanges.slotsAssignName) { setupCodeModifies.push([() => codes.push(`const __VLS_slots = `), scriptSetupRanges.defineSlots.start, scriptSetupRanges.defineSlots.start]); diff --git a/packages/vue-test-workspace/vue-tsc/non-strict-template/#3629/main.vue b/packages/vue-test-workspace/vue-tsc/non-strict-template/#3629/main.vue new file mode 100644 index 0000000000..74f2ca3a04 --- /dev/null +++ b/packages/vue-test-workspace/vue-tsc/non-strict-template/#3629/main.vue @@ -0,0 +1,7 @@ + \ No newline at end of file