@@ -54,16 +54,19 @@ function* generateTemplateCtx(options: ScriptCodegenOptions): Generator<Code> {
54
54
}
55
55
56
56
function * generateTemplateComponents ( options : ScriptCodegenOptions ) : Generator < Code > {
57
- const exps : Code [ ] = [ ] ;
57
+ const types : Code [ ] = [ ] ;
58
58
59
59
if ( options . sfc . script && options . scriptRanges ?. exportDefault ?. componentsOption ) {
60
60
const { componentsOption } = options . scriptRanges . exportDefault ;
61
- exps . push ( [
61
+ yield `const __VLS_componentsOption = `
62
+ yield [
62
63
options . sfc . script . content . slice ( componentsOption . start , componentsOption . end ) ,
63
64
'script' ,
64
65
componentsOption . start ,
65
66
codeFeatures . navigation ,
66
- ] ) ;
67
+ ] ;
68
+ yield endOfLine ;
69
+ types . push ( `typeof __VLS_componentsOption` ) ;
67
70
}
68
71
69
72
let nameType : Code | undefined ;
@@ -76,52 +79,51 @@ function* generateTemplateComponents(options: ScriptCodegenOptions): Generator<C
76
79
nameType = `'${ options . scriptSetupRanges ?. defineOptions ?. name ?? baseName . slice ( 0 , baseName . lastIndexOf ( '.' ) ) } '` ;
77
80
}
78
81
if ( nameType ) {
79
- exps . push (
80
- `{} as { [K in ${ nameType } ]: typeof __VLS_self & (new () => { `
82
+ types . push (
83
+ `{ [K in ${ nameType } ]: typeof __VLS_self & (new () => { `
81
84
+ getSlotsPropertyName ( options . vueCompilerOptions . target )
82
85
+ `: typeof ${ options . scriptSetupRanges ?. defineSlots ?. name ?? `__VLS_slots` } }) }`
83
86
) ;
84
87
}
85
88
86
- exps . push ( `{} as NonNullable<typeof __VLS_self extends { components: infer C } ? C : {}>` ) ;
87
- exps . push ( `__VLS_ctx` ) ;
89
+ types . push ( `typeof __VLS_ctx` ) ;
88
90
89
- yield `const __VLS_localComponents = { ${ newLine } ` ;
90
- for ( const type of exps ) {
91
- yield `... ` ;
91
+ yield `type __VLS_LocalComponents = ` ;
92
+ for ( const type of types ) {
93
+ yield ` & ` ;
92
94
yield type ;
93
- yield `,${ newLine } ` ;
94
95
}
95
- yield `} ${ endOfLine } ` ;
96
+ yield endOfLine ;
96
97
97
- yield `let __VLS_components!: typeof __VLS_localComponents & __VLS_GlobalComponents${ endOfLine } ` ;
98
+ yield `let __VLS_components!: __VLS_LocalComponents & __VLS_GlobalComponents${ endOfLine } ` ;
98
99
}
99
100
100
101
export function * generateTemplateDirectives ( options : ScriptCodegenOptions ) : Generator < Code > {
101
- const exps : Code [ ] = [ ] ;
102
+ const types : Code [ ] = [ ] ;
102
103
103
104
if ( options . sfc . script && options . scriptRanges ?. exportDefault ?. directivesOption ) {
104
105
const { directivesOption } = options . scriptRanges . exportDefault ;
105
- exps . push ( [
106
+ yield `const __VLS_directivesOption = ` ;
107
+ yield [
106
108
options . sfc . script . content . slice ( directivesOption . start , directivesOption . end ) ,
107
109
'script' ,
108
110
directivesOption . start ,
109
111
codeFeatures . navigation ,
110
- ] ) ;
112
+ ] ;
113
+ yield endOfLine ;
114
+ types . push ( `typeof __VLS_directivesOption` ) ;
111
115
}
112
116
113
- exps . push ( `{} as NonNullable<typeof __VLS_self extends { directives: infer D } ? D : {}>` ) ;
114
- exps . push ( `__VLS_ctx` ) ;
117
+ types . push ( `typeof __VLS_ctx` ) ;
115
118
116
- yield `const __VLS_localDirectives = { ${ newLine } ` ;
117
- for ( const type of exps ) {
118
- yield `... ` ;
119
+ yield `type __VLS_LocalDirectives = ` ;
120
+ for ( const type of types ) {
121
+ yield ` & ` ;
119
122
yield type ;
120
- yield `,${ newLine } ` ;
121
123
}
122
- yield `} ${ endOfLine } ` ;
124
+ yield endOfLine ;
123
125
124
- yield `let __VLS_directives!: typeof __VLS_localDirectives & __VLS_GlobalDirectives${ endOfLine } ` ;
126
+ yield `let __VLS_directives!: __VLS_LocalDirectives & __VLS_GlobalDirectives${ endOfLine } ` ;
125
127
}
126
128
127
129
function * generateTemplateBody (
0 commit comments