1- import { camelize , capitalize } from '@vue/shared' ;
21import * as path from 'path-browserify' ;
32import type { Code } from '../../types' ;
43import { codeFeatures } from '../codeFeatures' ;
@@ -13,7 +12,7 @@ export function* generateTemplate(
1312 ctx : ScriptCodegenContext ,
1413) : Generator < Code > {
1514 yield * generateSelf ( options ) ;
16- yield * generateBindings ( options , ctx ) ;
15+ yield * generateSetupExposed ( options , ctx ) ;
1716 yield * generateTemplateCtx ( options , ctx ) ;
1817 yield * generateTemplateComponents ( options ) ;
1918 yield * generateTemplateDirectives ( options ) ;
@@ -92,8 +91,8 @@ function* generateTemplateCtx(
9291 exps . push ( [ `{} as ${ names . InternalProps } ` ] ) ;
9392 }
9493
95- if ( ctx . generatedTypes . has ( names . Bindings ) ) {
96- exps . push ( [ `{} as ${ names . Bindings } ` ] ) ;
94+ if ( ctx . generatedTypes . has ( names . SetupExposed ) ) {
95+ exps . push ( [ `{} as ${ names . SetupExposed } ` ] ) ;
9796 }
9897
9998 yield `const ${ names . ctx } = ` ;
@@ -141,23 +140,17 @@ function* generateTemplateDirectives(options: ScriptCodegenOptions): Generator<C
141140 yield `let ${ names . directives } !: __VLS_LocalDirectives & __VLS_GlobalDirectives${ endOfLine } ` ;
142141}
143142
144- function * generateBindings (
145- { templateComponents , templateCodegen , styleCodegen , setupBindingNames } : ScriptCodegenOptions ,
143+ function * generateSetupExposed (
144+ { setupExposed } : ScriptCodegenOptions ,
146145 ctx : ScriptCodegenContext ,
147146) : Generator < Code > {
148- const testNames = new Set ( [
149- ...templateComponents . flatMap ( c => [ camelize ( c ) , capitalize ( camelize ( c ) ) ] ) ,
150- ...templateCodegen ?. accessExternalVariables . keys ( ) ?? [ ] ,
151- ...styleCodegen ?. accessExternalVariables . keys ( ) ?? [ ] ,
152- ] ) ;
153- const exposeNames = [ ...setupBindingNames ] . filter ( name => testNames . has ( name ) ) ;
154- if ( exposeNames . length === 0 ) {
147+ if ( ! setupExposed . size ) {
155148 return ;
156149 }
157- ctx . generatedTypes . add ( names . Bindings ) ;
150+ ctx . generatedTypes . add ( names . SetupExposed ) ;
158151
159- yield `type ${ names . Bindings } = __VLS_ProxyRefs<{${ newLine } ` ;
160- for ( const bindingName of exposeNames ) {
152+ yield `type ${ names . SetupExposed } = __VLS_ProxyRefs<{${ newLine } ` ;
153+ for ( const bindingName of setupExposed ) {
161154 const token = Symbol ( bindingName . length ) ;
162155 yield [ '' , undefined , 0 , { __linkedToken : token } ] ;
163156 yield `${ bindingName } : typeof ` ;
0 commit comments