@@ -30,7 +30,9 @@ interface GlobalCLIOptions {
3030/**
3131 * removing global flags before passing as command specific sub-configs
3232 */
33- function cleanOptions ( options : GlobalCLIOptions ) {
33+ function cleanOptions < Options extends GlobalCLIOptions > (
34+ options : Options
35+ ) : Omit < Options , keyof GlobalCLIOptions > {
3436 const ret = { ...options }
3537 delete ret [ '--' ]
3638 delete ret . debug
8688 configFile : options . config ,
8789 logLevel : options . logLevel ,
8890 clearScreen : options . clearScreen ,
89- server : cleanOptions ( options ) as ServerOptions
91+ server : cleanOptions ( options )
9092 } )
9193 await server . listen ( )
9294 } catch ( e ) {
133135 . option ( '-w, --watch' , `[boolean] rebuilds when modules have changed on disk` )
134136 . action ( async ( root : string , options : BuildOptions & GlobalCLIOptions ) => {
135137 const { build } = await import ( './build' )
136- const buildOptions = cleanOptions ( options ) as BuildOptions
138+ const buildOptions : BuildOptions = cleanOptions ( options )
137139
138140 try {
139141 await build ( {
195197 async (
196198 root : string ,
197199 options : {
198- host ?: string
200+ host ?: string | boolean
199201 port ?: number
200202 https ?: boolean
201203 open ?: boolean | string
218220 'serve' ,
219221 'development'
220222 )
221- await preview (
222- config ,
223- cleanOptions ( options ) as {
224- host ?: string
225- port ?: number
226- }
227- )
223+ await preview ( config , cleanOptions ( options ) )
228224 } catch ( e ) {
229225 createLogger ( options . logLevel ) . error (
230226 chalk . red ( `error when starting preview server:\n${ e . stack } ` )
0 commit comments