@@ -58,22 +58,18 @@ function useCodegen(
5858) {
5959 const ts = ctx . modules . typescript ;
6060
61- const getRawLang = computed ( ( ) => {
61+ const getLang = computed ( ( ) => {
62+ let lang = sfc . scriptSetup ?. lang ?? sfc . script ?. lang ;
6263 if ( sfc . script && sfc . scriptSetup ) {
6364 if ( sfc . scriptSetup . lang !== 'js' ) {
64- return sfc . scriptSetup . lang ;
65+ lang = sfc . scriptSetup . lang ;
6566 }
6667 else {
67- return sfc . script . lang ;
68+ lang = sfc . script . lang ;
6869 }
6970 }
70- return sfc . scriptSetup ?. lang ?? sfc . script ?. lang ;
71- } ) ;
72-
73- const getLang = computed ( ( ) => {
74- const rawLang = getRawLang ( ) ;
75- if ( rawLang && validLangs . has ( rawLang ) ) {
76- return rawLang ;
71+ if ( lang && validLangs . has ( lang ) ) {
72+ return lang ;
7773 }
7874 return 'ts' ;
7975 } ) ;
@@ -139,7 +135,7 @@ function useCodegen(
139135 return names ;
140136 } ) ;
141137
142- const getDestructuredPropNames = computedSet ( ( ) => {
138+ const getRawBindingNames = computedSet ( ( ) => {
143139 const names = new Set ( [
144140 ...getScriptSetupRanges ( ) ?. defineProps ?. destructured ?. keys ( ) ?? [ ] ,
145141 ...getImportComponentNames ( ) ,
@@ -151,7 +147,7 @@ function useCodegen(
151147 return names ;
152148 } ) ;
153149
154- const getSetupTemplateRefNames = computedSet ( ( ) => {
150+ const getTemplateRefNames = computedSet ( ( ) => {
155151 const newNames = new Set (
156152 getScriptSetupRanges ( ) ?. useTemplateRef
157153 . map ( ( { name } ) => name )
@@ -160,11 +156,11 @@ function useCodegen(
160156 return newNames ;
161157 } ) ;
162158
163- const setupHasDefineSlots = computed ( ( ) => ! ! getScriptSetupRanges ( ) ?. defineSlots ) ;
159+ const hasDefineSlots = computed ( ( ) => ! ! getScriptSetupRanges ( ) ?. defineSlots ) ;
164160
165- const getSetupPropsAssignName = computed ( ( ) => getScriptSetupRanges ( ) ?. defineProps ?. name ) ;
161+ const getDefinePropsName = computed ( ( ) => getScriptSetupRanges ( ) ?. defineProps ?. name ) ;
166162
167- const getSetupSlotsAssignName = computed ( ( ) => getScriptSetupRanges ( ) ?. defineSlots ?. name ) ;
163+ const getDefineSlotsName = computed ( ( ) => getScriptSetupRanges ( ) ?. defineSlots ?. name ) ;
168164
169165 const getSetupInheritAttrs = computed ( ( ) => {
170166 const value = getScriptSetupRanges ( ) ?. defineOptions ?. inheritAttrs
@@ -203,12 +199,12 @@ function useCodegen(
203199 compilerOptions : ctx . compilerOptions ,
204200 vueCompilerOptions : getResolvedOptions ( ) ,
205201 template : sfc . template ,
206- rawBindingNames : getDestructuredPropNames ( ) ,
202+ rawBindingNames : getRawBindingNames ( ) ,
207203 setupBindingNames : getSetupBindingNames ( ) ,
208- templateRefNames : getSetupTemplateRefNames ( ) ,
209- hasDefineSlots : setupHasDefineSlots ( ) ,
210- propsAssignName : getSetupPropsAssignName ( ) ,
211- slotsAssignName : getSetupSlotsAssignName ( ) ,
204+ templateRefNames : getTemplateRefNames ( ) ,
205+ hasDefineSlots : hasDefineSlots ( ) ,
206+ propsAssignName : getDefinePropsName ( ) ,
207+ slotsAssignName : getDefineSlotsName ( ) ,
212208 inheritAttrs : getSetupInheritAttrs ( ) ,
213209 selfComponentName : getComponentSelfName ( ) ,
214210 } ) ;
@@ -253,8 +249,8 @@ function useCodegen(
253249 vueCompilerOptions : getResolvedOptions ( ) ,
254250 usedCssModule : usedCssModule ( ) ,
255251 styles : sfc . styles ,
256- rawBindingNames : getDestructuredPropNames ( ) ,
257- templateRefNames : getSetupTemplateRefNames ( ) ,
252+ rawBindingNames : getRawBindingNames ( ) ,
253+ templateRefNames : getTemplateRefNames ( ) ,
258254 setupBindingNames : getSetupBindingNames ( ) ,
259255 } ) ;
260256 const codes : Code [ ] = [ ] ;
@@ -279,7 +275,7 @@ function useCodegen(
279275 getLang,
280276 getScriptRanges,
281277 getScriptSetupRanges,
282- getSetupSlotsAssignName,
278+ getSetupSlotsAssignName : getDefineSlotsName ,
283279 getGeneratedScript,
284280 getGeneratedTemplate,
285281 } ;
0 commit comments