@@ -122,23 +122,28 @@ function updateParsedCommandLine(parsedCommandLine: ts.ParsedCommandLine, args:
122122
123123 if ( option ) {
124124 // Ignore errors caused by tstl specific compiler options
125- const tsInvalidCompilerOptionErrorCode = 5023 ;
126125 parsedCommandLine . errors = parsedCommandLine . errors . filter (
127- e => ! ( e . code === tsInvalidCompilerOptionErrorCode && String ( e . messageText ) . endsWith ( `'${ args [ i ] } '.` ) )
126+ // TS5023: Unknown compiler option '{0}'.
127+ // TS5025: Unknown compiler option '{0}'. Did you mean '{1}'?
128+ e => ! ( ( e . code === 5023 || e . code === 5025 ) && String ( e . messageText ) . includes ( `'${ args [ i ] } '.` ) )
128129 ) ;
129130
130- const { error, value, increment } = readCommandLineArgument ( option , args [ i + 1 ] ) ;
131+ const { error, value, consumed } = readCommandLineArgument ( option , args [ i + 1 ] ) ;
131132 if ( error ) parsedCommandLine . errors . push ( error ) ;
132133 parsedCommandLine . options [ option . name ] = value ;
133- i += increment ;
134+ if ( consumed ) {
135+ i += 1 ;
136+ // Values of custom options are parsed as a file name, exclude them
137+ parsedCommandLine . fileNames = parsedCommandLine . fileNames . filter ( f => f !== value ) ;
138+ }
134139 }
135140 }
136141
137142 return parsedCommandLine ;
138143}
139144
140145interface CommandLineArgument extends ReadValueResult {
141- increment : number ;
146+ consumed : boolean ;
142147}
143148
144149function readCommandLineArgument ( option : CommandLineOption , value : any ) : CommandLineArgument {
@@ -147,19 +152,19 @@ function readCommandLineArgument(option: CommandLineOption, value: any): Command
147152 value = value === "true" ;
148153 } else {
149154 // Set boolean arguments without supplied value to true
150- return { value : true , increment : 0 } ;
155+ return { value : true , consumed : false } ;
151156 }
152157 }
153158
154159 if ( value === undefined ) {
155160 return {
156161 error : cliDiagnostics . compilerOptionExpectsAnArgument ( option . name ) ,
157162 value : undefined ,
158- increment : 0 ,
163+ consumed : false ,
159164 } ;
160165 }
161166
162- return { ...readValue ( option , value ) , increment : 1 } ;
167+ return { ...readValue ( option , value ) , consumed : true } ;
163168}
164169
165170interface ReadValueResult {
0 commit comments