@@ -18,15 +18,11 @@ interface CommandLineOptionOfEnum extends CommandLineOptionBase {
1818 choices : string [ ] ;
1919}
2020
21- interface CommandLineOptionOfBoolean extends CommandLineOptionBase {
22- type : "boolean" ;
21+ interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase {
22+ type : "string" | " boolean";
2323}
2424
25- interface CommandLineOptionOfString extends CommandLineOptionBase {
26- type : "string" ;
27- }
28-
29- type CommandLineOption = CommandLineOptionOfEnum | CommandLineOptionOfBoolean | CommandLineOptionOfString ;
25+ type CommandLineOption = CommandLineOptionOfEnum | CommandLineOptionOfPrimitiveType ;
3026
3127const optionDeclarations : CommandLineOption [ ] = [
3228 {
@@ -206,11 +202,12 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
206202 if ( value === null ) return { value } ;
207203
208204 switch ( option . type ) {
205+ case "string" :
209206 case "boolean" : {
210- if ( typeof value !== "boolean" ) {
207+ if ( typeof value !== option . type ) {
211208 return {
212209 value : undefined ,
213- error : diagnosticFactories . compilerOptionRequiresAValueOfType ( option . name , "boolean" ) ,
210+ error : diagnosticFactories . compilerOptionRequiresAValueOfType ( option . name , option . type ) ,
214211 } ;
215212 }
216213
@@ -236,17 +233,6 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
236233
237234 return { value : enumValue } ;
238235 }
239-
240- case "string" : {
241- if ( typeof value !== "string" ) {
242- return {
243- value : undefined ,
244- error : diagnosticFactories . compilerOptionRequiresAValueOfType ( option . name , "string" ) ,
245- } ;
246- }
247-
248- return { value } ;
249- }
250236 }
251237}
252238
0 commit comments