@@ -21,16 +21,16 @@ function toArr(any: any) {
2121 return any == undefined ? [ ] : Array . isArray ( any ) ? any : [ any ] ;
2222}
2323
24- function toVal ( out , key , val , opts ) {
24+ function toVal ( out : any , key : string , val : any , opts : Options ) {
2525 let x ;
2626 const old = out [ key ] ;
27- const nxt = ~ opts . string . indexOf ( key )
27+ const nxt = ~ opts . string ! . indexOf ( key )
2828 ? val == undefined || val === true
2929 ? ""
3030 : String ( val )
3131 : typeof val === "boolean"
3232 ? val
33- : ~ opts . boolean . indexOf ( key )
33+ : ~ opts . boolean ! . indexOf ( key )
3434 ? val === "false"
3535 ? false
3636 : val === "true" ||
@@ -51,7 +51,7 @@ export function parseRawArgs<T = Default>(
5151 let arg ;
5252 let name ;
5353 let val ;
54- const out = { _ : [ ] } ;
54+ const out = { _ : [ ] as string [ ] } as Argv < T > ;
5555 let i = 0 ;
5656 let j = 0 ;
5757 let idx = 0 ;
@@ -75,27 +75,27 @@ export function parseRawArgs<T = Default>(
7575 }
7676
7777 for ( i = opts . boolean . length ; i -- > 0 ; ) {
78- arr = opts . alias [ opts . boolean [ i ] ] || [ ] ;
78+ arr = opts . alias [ opts . boolean [ i ] ! ] || [ ] ;
7979 for ( j = arr . length ; j -- > 0 ; ) {
80- opts . boolean . push ( arr [ j ] ) ;
80+ opts . boolean . push ( arr [ j ] ! ) ;
8181 }
8282 }
8383
8484 for ( i = opts . string . length ; i -- > 0 ; ) {
85- arr = opts . alias [ opts . string [ i ] ] || [ ] ;
85+ arr = opts . alias [ opts . string [ i ] ! ] || [ ] ;
8686 for ( j = arr . length ; j -- > 0 ; ) {
87- opts . string . push ( arr [ j ] ) ;
87+ opts . string . push ( arr [ j ] as string ) ;
8888 }
8989 }
9090
9191 if ( defaults ) {
9292 for ( k in opts . default ) {
93- name = typeof opts . default [ k ] ;
93+ name = typeof ( opts as any ) . default [ k ] ;
9494 arr = opts . alias [ k ] = opts . alias [ k ] || [ ] ;
95- if ( opts [ name ] !== void 0 ) {
96- opts [ name ] . push ( k ) ;
95+ if ( ( opts as any ) [ name ] !== void 0 ) {
96+ ( opts as any ) [ name ] . push ( k ) ;
9797 for ( i = 0 ; i < arr . length ; i ++ ) {
98- opts [ name ] . push ( arr [ i ] ) ;
98+ ( opts as any ) [ name ] . push ( arr [ i ] ) ;
9999 }
100100 }
101101 }
@@ -104,7 +104,7 @@ export function parseRawArgs<T = Default>(
104104 const keys = strict ? Object . keys ( opts . alias ) : [ ] ;
105105
106106 for ( i = 0 ; i < len ; i ++ ) {
107- arg = args [ i ] ;
107+ arg = args [ i ] ! ;
108108
109109 if ( arg === "--" ) {
110110 out . _ = out . _ . concat ( args . slice ( ++ i ) ) ;
@@ -122,9 +122,9 @@ export function parseRawArgs<T = Default>(
122122 } else if ( arg . substring ( j , j + 3 ) === "no-" ) {
123123 name = arg . slice ( Math . max ( 0 , j + 3 ) ) ;
124124 if ( strict && ! ~ keys . indexOf ( name ) ) {
125- return opts . unknown ( arg ) ;
125+ return opts . unknown ! ( arg ) ! ;
126126 }
127- out [ name ] = false ;
127+ ( out as any ) [ name ] = false ;
128128 } else {
129129 for ( idx = j + 1 ; idx < arg . length ; idx ++ ) {
130130 if ( arg . charCodeAt ( idx ) === 61 ) {
@@ -142,18 +142,18 @@ export function parseRawArgs<T = Default>(
142142
143143 for ( idx = 0 ; idx < arr . length ; idx ++ ) {
144144 name = arr [ idx ] ;
145- if ( strict && ! ~ keys . indexOf ( name ) ) {
146- return opts . unknown ( "-" . repeat ( j ) + name ) ;
145+ if ( strict && ! ~ keys . indexOf ( name ! ) ) {
146+ return opts . unknown ! ( "-" . repeat ( j ) + name ) ! ;
147147 }
148- toVal ( out , name , idx + 1 < arr . length || val , opts ) ;
148+ toVal ( out , name ! , idx + 1 < arr . length || val , opts ) ;
149149 }
150150 }
151151 }
152152
153153 if ( defaults ) {
154154 for ( k in opts . default ) {
155- if ( out [ k ] === void 0 ) {
156- out [ k ] = opts . default [ k ] ;
155+ if ( ( out as any ) [ k ] === void 0 ) {
156+ ( out as any ) [ k ] = opts . default ! [ k ] ;
157157 }
158158 }
159159 }
@@ -162,7 +162,7 @@ export function parseRawArgs<T = Default>(
162162 for ( k in out ) {
163163 arr = opts . alias [ k ] || [ ] ;
164164 while ( arr . length > 0 ) {
165- out [ arr . shift ( ) ] = out [ k ] ;
165+ ( out as any ) [ ( arr as string [ ] ) . shift ( ) ! ] = ( out as any ) [ k ] ;
166166 }
167167 }
168168 }
0 commit comments