@@ -122,31 +122,39 @@ function* generatePropsOption(
122122 scriptSetupRanges : ScriptSetupRanges ,
123123 hasEmitsOption : boolean ,
124124) : Generator < Code > {
125- const optionGenerates : Iterable < Code > [ ] = [ ] ;
126- const typeOptionGenerates : Iterable < Code > [ ] = [ ] ;
125+ const optionGenerates : ( ( ) => Iterable < Code > ) [ ] = [ ] ;
126+ const typeOptionGenerates : ( ( ) => Iterable < Code > ) [ ] = [ ] ;
127127
128128 if ( options . templateCodegen ?. generatedTypes . has ( names . InheritedAttrs ) ) {
129129 const attrsType = hasEmitsOption
130130 ? `Omit<${ names . InheritedAttrs } , keyof ${ names . EmitProps } >`
131131 : names . InheritedAttrs ;
132- const propsType = `__VLS_PickNotAny<${ ctx . localTypes . OmitIndexSignature } <${ attrsType } >, {}>` ;
133- const optionType = `${ ctx . localTypes . TypePropsToOption } <${ propsType } >` ;
134- optionGenerates . push ( [ `{} as ${ optionType } ` ] ) ;
135- typeOptionGenerates . push ( [ `{} as ${ attrsType } ` ] ) ;
132+ optionGenerates . push ( function * ( ) {
133+ const propsType = `__VLS_PickNotAny<${ ctx . localTypes . OmitIndexSignature } <${ attrsType } >, {}>` ;
134+ const optionType = `${ ctx . localTypes . TypePropsToOption } <${ propsType } >` ;
135+ yield `{} as ${ optionType } ` ;
136+ } ) ;
137+ typeOptionGenerates . push ( function * ( ) {
138+ yield `{} as ${ attrsType } ` ;
139+ } ) ;
136140 }
137141 if ( ctx . generatedTypes . has ( names . PublicProps ) ) {
138142 if ( options . vueCompilerOptions . target < 3.6 ) {
139- let propsType = `${ ctx . localTypes . TypePropsToOption } <${ names . PublicProps } >` ;
140- if ( scriptSetupRanges . withDefaults ?. arg ) {
141- propsType = `${ ctx . localTypes . WithDefaultsLocal } <${ propsType } , typeof ${ names . defaults } >` ;
142- }
143- optionGenerates . push ( [ `{} as ${ propsType } ` ] ) ;
143+ optionGenerates . push ( function * ( ) {
144+ let propsType = `${ ctx . localTypes . TypePropsToOption } <${ names . PublicProps } >` ;
145+ if ( scriptSetupRanges . withDefaults ?. arg ) {
146+ propsType = `${ ctx . localTypes . WithDefaultsLocal } <${ propsType } , typeof ${ names . defaults } >` ;
147+ }
148+ yield `{} as ${ propsType } ` ;
149+ } ) ;
144150 }
145- typeOptionGenerates . push ( [ `{} as ${ names . PublicProps } ` ] ) ;
151+ typeOptionGenerates . push ( function * ( ) {
152+ yield `{} as ${ names . PublicProps } ` ;
153+ } ) ;
146154 }
147155 if ( scriptSetupRanges . defineProps ?. arg ) {
148156 const { arg } = scriptSetupRanges . defineProps ;
149- optionGenerates . push ( generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . navigation ) ) ;
157+ optionGenerates . push ( ( ) => generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . navigation ) ) ;
150158 typeOptionGenerates . length = 0 ;
151159 }
152160
@@ -161,12 +169,12 @@ function* generatePropsOption(
161169 yield `__defaults: ${ names . defaults } ,${ newLine } ` ;
162170 }
163171 yield `__typeProps: ` ;
164- yield * generateSpreadMerge ( typeOptionGenerates ) ;
172+ yield * generateSpreadMerge ( typeOptionGenerates . map ( g => g ( ) ) ) ;
165173 yield `,${ newLine } ` ;
166174 }
167175 if ( useOption ) {
168176 yield `props: ` ;
169- yield * generateSpreadMerge ( optionGenerates ) ;
177+ yield * generateSpreadMerge ( optionGenerates . map ( g => g ( ) ) ) ;
170178 yield `,${ newLine } ` ;
171179 }
172180}
0 commit comments