@@ -20,12 +20,12 @@ export function* generateTemplate(
20
20
const templateCodegenCtx = createTemplateCodegenContext ( {
21
21
scriptSetupBindingNames : new Set ( ) ,
22
22
} ) ;
23
- yield * generateBindings ( options , ctx ) ;
24
23
yield * generateTemplateCtx ( options , ctx ) ;
25
24
yield * generateTemplateElements ( ) ;
26
25
yield * generateTemplateComponents ( options ) ;
27
26
yield * generateTemplateDirectives ( options ) ;
28
27
yield * generateTemplateBody ( options , templateCodegenCtx ) ;
28
+ yield * generateBindings ( options , ctx , templateCodegenCtx ) ;
29
29
30
30
if ( options . sfc . script && options . scriptRanges ?. exportDefault ) {
31
31
yield `const __VLS_self = (await import('${ options . vueCompilerOptions . lib } ')).defineComponent(` ;
@@ -183,6 +183,7 @@ function* generateCssVars(options: ScriptCodegenOptions, ctx: TemplateCodegenCon
183
183
function * generateBindings (
184
184
options : ScriptCodegenOptions ,
185
185
ctx : ScriptCodegenContext ,
186
+ templateCodegenCtx : TemplateCodegenContext ,
186
187
) : Generator < Code > {
187
188
yield `type __VLS_Bindings = __VLS_ProxyRefs<{${ newLine } ` ;
188
189
if ( options . sfc . scriptSetup && options . scriptSetupRanges ) {
@@ -197,7 +198,7 @@ function* generateBindings(
197
198
) {
198
199
for ( const { range } of bindings ) {
199
200
const varName = content . slice ( range . start , range . end ) ;
200
- if ( ! templateUsageVars . has ( varName ) ) {
201
+ if ( ! templateUsageVars . has ( varName ) && ! templateCodegenCtx . accessExternalVariables . has ( varName ) ) {
201
202
continue ;
202
203
}
203
204
0 commit comments