@@ -41,23 +41,23 @@ function* generateTemplateCtx(
41
41
) : Generator < Code > {
42
42
const exps : Code [ ] = [ ] ;
43
43
44
+ if ( options . vueCompilerOptions . petiteVueExtensions . some ( ext => options . fileName . endsWith ( ext ) ) ) {
45
+ exps . push ( `globalThis` ) ;
46
+ }
44
47
if ( options . sfc . script && options . scriptRanges ?. exportDefault ) {
45
48
exps . push ( `{} as InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>` ) ;
46
49
}
47
50
else {
48
51
exps . push ( `{} as import('${ options . vueCompilerOptions . lib } ').ComponentPublicInstance` ) ;
49
52
}
50
-
51
- if ( options . vueCompilerOptions . petiteVueExtensions . some ( ext => options . fileName . endsWith ( ext ) ) ) {
52
- exps . push ( `globalThis` ) ;
53
- }
54
53
if ( options . sfc . styles . some ( style => style . module ) ) {
55
54
exps . push ( `{} as __VLS_StyleModules` ) ;
56
55
}
57
56
58
- const emitTypes : Code [ ] = [ ] ;
57
+ const emitTypes : string [ ] = [ ] ;
59
58
if ( options . scriptSetupRanges ?. defineEmits ) {
60
- emitTypes . push ( `typeof ${ options . scriptSetupRanges . defineEmits . name ?? `__VLS_emit` } ` ) ;
59
+ const { defineEmits } = options . scriptSetupRanges ;
60
+ emitTypes . push ( `typeof ${ defineEmits . name ?? `__VLS_emit` } ` ) ;
61
61
}
62
62
if ( options . scriptSetupRanges ?. defineModel . length ) {
63
63
emitTypes . push ( `typeof __VLS_modelEmit` ) ;
@@ -67,19 +67,19 @@ function* generateTemplateCtx(
67
67
exps . push ( `{} as { $emit: ${ emitTypes . join ( ' & ' ) } }` ) ;
68
68
}
69
69
70
- if ( options . scriptSetupRanges ?. defineProps || ctx . generatedPropsType || emitTypes . length ) {
71
- yield `type __VLS_InternalProps =` ;
72
- const { defineProps } = options . scriptSetupRanges ?? { } ;
73
- if ( defineProps ) {
74
- yield ` __VLS_SpreadMerge<__VLS_PublicProps, typeof ${ defineProps . name ?? `__VLS_props` } >` ;
75
- }
76
- else if ( ctx . generatedPropsType ) {
77
- yield ` __VLS_PublicProps` ;
78
- }
79
- if ( emitTypes . length ) {
80
- yield ` & __VLS_EmitProps` ;
81
- }
82
- yield endOfLine ;
70
+ const propTypes : string [ ] = [ ] ;
71
+ if ( options . scriptSetupRanges ?. defineProps ) {
72
+ const { defineProps } = options . scriptSetupRanges ;
73
+ propTypes . push ( `__VLS_SpreadMerge<__VLS_PublicProps, typeof ${ defineProps . name ?? `__VLS_props` } >` ) ;
74
+ }
75
+ else if ( ctx . generatedPropsType ) {
76
+ propTypes . push ( `__VLS_PublicProps` ) ;
77
+ }
78
+ if ( emitTypes . length ) {
79
+ propTypes . push ( `__VLS_EmitProps` ) ;
80
+ }
81
+ if ( propTypes . length ) {
82
+ yield `type __VLS_InternalProps = ${ propTypes . join ( ' & ' ) } ${ endOfLine } ` ;
83
83
exps . push ( `{} as { $props: __VLS_InternalProps }` ) ;
84
84
exps . push ( `{} as __VLS_InternalProps` ) ;
85
85
}
0 commit comments