File tree Expand file tree Collapse file tree 4 files changed +27
-7
lines changed
language-core/lib/codegen/script
test-workspace/tsc/passedFixtures/vue3/#4391 Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,21 @@ export function* generateTemplate(
18
18
19
19
if ( ! options . vueCompilerOptions . skipTemplateCodegen ) {
20
20
if ( isClassComponent ) {
21
- yield `__VLS_template() {${ newLine } ` ;
21
+ yield `__VLS_template = (() => {${ newLine } ` ;
22
22
}
23
23
else {
24
- yield `function __VLS_template() {${ newLine } ` ;
24
+ yield `const __VLS_template = (() => {${ newLine } ` ;
25
25
}
26
26
const templateCodegenCtx = createTemplateCodegenContext ( new Set ( ) ) ;
27
+ yield `const __VLS_template_return = () => {${ newLine } ` ;
27
28
yield * generateCtx ( options , isClassComponent ) ;
28
29
yield * generateTemplateContext ( options , templateCodegenCtx ) ;
29
30
yield * generateExportOptions ( options ) ;
30
31
yield * generateConstNameOption ( options ) ;
32
+ yield `}${ endOfLine } ` ;
31
33
yield * generateInternalComponent ( options , ctx , templateCodegenCtx ) ;
32
- yield `}${ newLine } ` ;
34
+ yield `return __VLS_template_return${ endOfLine } ` ;
35
+ yield `})()${ endOfLine } ` ;
33
36
}
34
37
else {
35
38
yield `function __VLS_template() {${ newLine } ` ;
Original file line number Diff line number Diff line change @@ -656,7 +656,7 @@ export {};
656
656
`;
657
657
658
658
exports[`vue-tsc-dts > Input: template-slots/component.vue, Output: template-slots/component.vue.d.ts 1`] = `
659
- "declare function __VLS_template(): {
659
+ "declare const __VLS_template: () => {
660
660
slots : {
661
661
" no-bind" ? (_ : {}): any ;
662
662
default? (_ : {
@@ -687,7 +687,7 @@ type __VLS_WithTemplateSlots<T, S> = T & {
687
687
688
688
exports[`vue-tsc-dts > Input: template-slots/component-define-slots.vue, Output: template-slots/component-define-slots.vue.d.ts 1`] = `
689
689
"import { VNode } from 'vue';
690
- declare function __VLS_template(): {
690
+ declare const __VLS_template: () => {
691
691
slots : Readonly < {
692
692
default: (props : {
693
693
num: number ;
@@ -729,7 +729,7 @@ type __VLS_WithTemplateSlots<T, S> = T & {
729
729
`;
730
730
731
731
exports[`vue-tsc-dts > Input: template-slots/component-destructuring.vue, Output: template-slots/component-destructuring.vue.d.ts 1`] = `
732
- "declare function __VLS_template(): {
732
+ "declare const __VLS_template: () => {
733
733
slots : Readonly < {
734
734
bottom: (props : {
735
735
num: number ;
@@ -755,7 +755,7 @@ type __VLS_WithTemplateSlots<T, S> = T & {
755
755
`;
756
756
757
757
exports[`vue-tsc-dts > Input: template-slots/component-no-script.vue, Output: template-slots/component-no-script.vue.d.ts 1`] = `
758
- "declare function __VLS_template(): {
758
+ "declare const __VLS_template: () => {
759
759
slots : {
760
760
" no-bind" ? (_ : {}): any ;
761
761
default? (_ : {
Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ defineProps <{
3
+ foo: number ;
4
+ }>();
5
+ </script >
Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ import Comp from ' ./comp.vue' ;
3
+
4
+ let value! : number | undefined ;
5
+ if (! value ) {
6
+ throw new Error (' undefined' );
7
+ }
8
+ </script >
9
+
10
+ <template >
11
+ <Comp :foo =" value" ></Comp >
12
+ </template >
You can’t perform that action at this time.
0 commit comments