@@ -212,22 +212,20 @@ export function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {
212212 type = { < CommandParameterType parameter = { arg } /> }
213213 initializer = {
214214 < >
215+ { code ` ( ` }
215216 < Show when = { isSetString ( arg . env ) } >
216217 { code `env.${ appSpecificEnvPrefix } _${ constantCase ( String ( arg . env ) ) } ?? ` }
217218 </ Show >
218219 < Show
219220 when = { arg . default !== undefined }
220- fallback = {
221- ( arg . kind === CommandParameterKinds . string ||
222- arg . kind === CommandParameterKinds . number ) &&
223- arg . variadic
224- ? code `[]`
225- : code `undefined;`
226- } >
221+ fallback = { arg . variadic ? code `[]` : code `undefined` } >
227222 { arg . kind === CommandParameterKinds . string
228223 ? code `"${ arg . default } "`
229224 : code `${ arg . default } ` }
230225 </ Show >
226+ { code `) as ` }
227+ < CommandParameterType parameter = { arg } />
228+ { code `; ` }
231229 </ >
232230 }
233231 />
@@ -247,16 +245,12 @@ export function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {
247245 />
248246 } >
249247 < Show
250- when = {
251- ( arg . kind === CommandParameterKinds . string ||
252- arg . kind === CommandParameterKinds . number ) &&
253- arg . variadic
254- }
248+ when = { arg . variadic }
255249 fallback = {
256250 < Show
257251 when = { arg . kind === CommandParameterKinds . number }
258- fallback = { code `args[argsIndex + ${ index } ]; ` } >
259- { code `Number(args[argsIndex + ${ index } ]); ` }
252+ fallback = { code `args[argsIndex + ${ index } ] ` } >
253+ { code `Number(args[argsIndex + ${ index } ]) ` }
260254 </ Show >
261255 } >
262256 { code `args.slice(argsIndex + ${
@@ -266,6 +260,9 @@ export function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {
266260 } ).join(" ").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean)`}
267261 </ Show >
268262 </ Show >
263+ { code ` as ` }
264+ < CommandParameterType parameter = { arg } />
265+ { code `; ` }
269266 </ IfStatement >
270267 < Spacing />
271268 </ >
@@ -654,10 +651,20 @@ export function OptionsMemberParserCondition(
654651export function OptionsInterfaceDeclaration ( props : { command : CommandTree } ) {
655652 const { command } = props ;
656653
657- const options = computed ( ( ) => computedOptions ( command ) ) ;
654+ const options = computed ( ( ) =>
655+ computedOptions (
656+ Object . entries ( command . options ) . map ( ( [ name , option ] ) => ( {
657+ ...option ,
658+ name
659+ } ) )
660+ )
661+ ) ;
658662
659663 return (
660- < InterfaceDeclaration export name = { `${ pascalCase ( command . name ) } Options` } >
664+ < InterfaceDeclaration
665+ export
666+ name = { `${ pascalCase ( command . name ) } Options` }
667+ extends = "GlobalOptions" >
661668 < For each = { Object . values ( options . value ) } hardline >
662669 { option => < OptionsMember option = { option } /> }
663670 </ For >
@@ -690,7 +697,14 @@ export interface OptionsParserLogicProps {
690697export function OptionsParserLogic ( props : OptionsParserLogicProps ) {
691698 const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props ;
692699
693- const options = computed ( ( ) => computedOptions ( command ) ) ;
700+ const options = computed ( ( ) =>
701+ computedOptions (
702+ Object . entries ( command . options ) . map ( ( [ name , option ] ) => ( {
703+ ...option ,
704+ name
705+ } ) )
706+ )
707+ ) ;
694708
695709 return (
696710 < >
@@ -755,7 +769,7 @@ export function OptionsParserLogic(props: OptionsParserLogicProps) {
755769 return "" ;
756770 } )
757771 . join ( "" ) }
758- } as ${ pascalCase ( command . name ) } Options;` }
772+ } as unknown as ${ pascalCase ( command . name ) } Options;` }
759773 />
760774 < Spacing />
761775 { code `for (let i = 0; i < args.slice(${
0 commit comments