@@ -103,6 +103,7 @@ import {
103103    returnTrue , 
104104    ScriptTarget , 
105105    startsWith , 
106+     stringContains , 
106107    StringLiteral , 
107108    SyntaxKind , 
108109    sys , 
@@ -1658,11 +1659,14 @@ export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value:
16581659} 
16591660
16601661/** @internal  */ 
1661- export  function  parseListTypeOption ( opt : CommandLineOptionOfListType ,  value  =  "" ,  errors : Push < Diagnostic > ) : ( string  |  number ) [ ]  |  undefined  { 
1662+ export  function  parseListTypeOption ( opt : CommandLineOptionOfListType ,  value  =  "" ,  errors : Push < Diagnostic > ) : string   |   ( string  |  number ) [ ]  |  undefined  { 
16621663    value  =  trimString ( value ) ; 
16631664    if  ( startsWith ( value ,  "-" ) )  { 
16641665        return  undefined ; 
16651666    } 
1667+     if  ( opt . type  ===  "string | list"  &&  ! stringContains ( value ,  "," ) )  { 
1668+         return  validateJsonOptionValue ( opt ,  value ,  errors ) ; 
1669+     } 
16661670    if  ( value  ===  "" )  { 
16671671        return  [ ] ; 
16681672    } 
@@ -1672,6 +1676,10 @@ export function parseListTypeOption(opt: CommandLineOptionOfListType, value = ""
16721676            return  mapDefined ( values ,  v  =>  validateJsonOptionValue ( opt . element ,  parseInt ( v ) ,  errors ) ) ; 
16731677        case  "string" :
16741678            return  mapDefined ( values ,  v  =>  validateJsonOptionValue ( opt . element ,  v  ||  "" ,  errors ) ) ; 
1679+         case  "boolean" :
1680+         case  "object" :
1681+         case  "string | list" :
1682+             return  Debug . fail ( `List of ${ opt . element . type }   is not yet supported.` ) ; 
16751683        default :
16761684            return  mapDefined ( values ,  v  =>  parseCustomTypeOption ( opt . element  as  CommandLineOptionOfCustomType ,  v ,  errors ) ) ; 
16771685    } 
@@ -1843,6 +1851,7 @@ function parseOptionValue(
18431851                    options [ opt . name ]  =  validateJsonOptionValue ( opt ,  args [ i ]  ||  "" ,  errors ) ; 
18441852                    i ++ ; 
18451853                    break ; 
1854+                 case  "string | list" :
18461855                case  "list" :
18471856                    const  result  =  parseListTypeOption ( opt ,  args [ i ] ,  errors ) ; 
18481857                    options [ opt . name ]  =  result  ||  [ ] ; 
@@ -2362,7 +2371,7 @@ export function convertToObjectWorker(
23622371                if  ( ! isDoubleQuotedString ( valueExpression ) )  { 
23632372                    errors . push ( createDiagnosticForNodeInSourceFile ( sourceFile ,  valueExpression ,  Diagnostics . String_literal_with_double_quotes_expected ) ) ; 
23642373                } 
2365-                 reportInvalidOptionValue ( option  &&  isString ( option . type )  &&  option . type  !==  "string"  &&  ( option . type  !==  "listOrElement"  ||  ( isString ( option . element . type )  &&  option . element . type  !==  "string" ) ) ) ; 
2374+                 reportInvalidOptionValue ( option  &&  isString ( option . type )  &&  option . type  !==  "string"  &&  ( option . type  !==  "listOrElement"  ||  ( isString ( option . element . type )  &&  option . element . type  !==  "string" ) )   &&   option . type   !==   "string | list" ) ; 
23662375                const  text  =  ( valueExpression  as  StringLiteral ) . text ; 
23672376                    if  ( option )  { 
23682377                        Debug . assert ( option . type  !==  "listOrElement"  ||  option . element . type  ===  "string" ,  "Only string or array of string is handled for now" ) ; 
@@ -2394,7 +2403,7 @@ export function convertToObjectWorker(
23942403                return  validateValue ( - Number ( ( ( valueExpression  as  PrefixUnaryExpression ) . operand  as  NumericLiteral ) . text ) ) ; 
23952404
23962405            case  SyntaxKind . ObjectLiteralExpression :
2397-                 reportInvalidOptionValue ( option  &&  option . type  !==  "object"  &&  ( option . type  !==  "listOrElement"  ||  option . element . type  !==  "object" ) ) ; 
2406+                 reportInvalidOptionValue ( option  &&  option . type  !==  "object"  &&  ( option . type  !==  "listOrElement"  ||  option . element . type  !==  "object" )   &&   option . type   !==   "string | list" ) ; 
23982407                const  objectLiteralExpression  =  valueExpression  as  ObjectLiteralExpression ; 
23992408
24002409                // Currently having element option declaration in the tsconfig with type "object" 
@@ -2472,6 +2481,9 @@ function isCompilerOptionsValue(option: CommandLineOption | undefined, value: an
24722481        if  ( option . type  ===  "listOrElement" )  { 
24732482            return  isArray ( value )  ||  isCompilerOptionsValue ( option . element ,  value ) ; 
24742483        } 
2484+         if  ( option . type  ===  "string | list" )  { 
2485+             return  typeof  value  ===  "string"  ||  isArray ( value ) ; 
2486+         } 
24752487        const  expectedType  =  isString ( option . type )  ? option . type  : "string" ; 
24762488        return  typeof  value  ===  expectedType ; 
24772489    } 
@@ -2576,15 +2588,29 @@ function matchesSpecs(path: string, includeSpecs: readonly string[] | undefined,
25762588} 
25772589
25782590function  getCustomTypeMapOfCommandLineOption ( optionDefinition : CommandLineOption ) : Map < string ,  string  |  number >  |  undefined  { 
2579-     if  ( optionDefinition . type  ===  "string"  ||  optionDefinition . type  ===  "number"  ||  optionDefinition . type  ===  "boolean"  ||  optionDefinition . type  ===  "object" )  { 
2580-         // this is of a type CommandLineOptionOfPrimitiveType 
2581-         return  undefined ; 
2582-     } 
2583-     else  if  ( optionDefinition . type  ===  "list"  ||  optionDefinition . type  ===  "listOrElement" )  { 
2584-         return  getCustomTypeMapOfCommandLineOption ( optionDefinition . element ) ; 
2585-     } 
2586-     else  { 
2587-         return  optionDefinition . type ; 
2591+     // if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") { 
2592+     //     // this is of a type CommandLineOptionOfPrimitiveType 
2593+     //     return undefined; 
2594+     // } 
2595+     // else if (optionDefinition.type === "list" || optionDefinition.type === "listOrElement") { 
2596+     //     return getCustomTypeMapOfCommandLineOption(optionDefinition.element); 
2597+     // } 
2598+     // else { 
2599+     //     return optionDefinition.type; 
2600+     // } 
2601+     switch  ( optionDefinition . type )  { 
2602+         case  "string" :
2603+         case  "number" :
2604+         case  "boolean" :
2605+         case  "object" :
2606+         case  "string | list" :
2607+             // this is of a type CommandLineOptionOfPrimitiveType 
2608+             return  undefined ; 
2609+         case  "list" :
2610+         case  "listOrElement" :
2611+             return  getCustomTypeMapOfCommandLineOption ( optionDefinition . element ) ; 
2612+         default :
2613+             return  optionDefinition . type ; 
25882614    } 
25892615} 
25902616
@@ -3495,15 +3521,15 @@ function convertOptionsFromJson(optionsNameMap: Map<string, CommandLineOption>,
34953521export  function  convertJsonOption ( opt : CommandLineOption ,  value : any ,  basePath : string ,  errors : Push < Diagnostic > ) : CompilerOptionsValue  { 
34963522    if  ( isCompilerOptionsValue ( opt ,  value ) )  { 
34973523        const  optType  =  opt . type ; 
3498-         if  ( optType  ===  "list"  &&  isArray ( value ) )  { 
3524+         if  ( ( optType  ===  "list"   ||   opt . type   ===   "string | list" )  &&  isArray ( value ) )  { 
34993525            return  convertJsonOptionOfListType ( opt ,  value ,  basePath ,  errors ) ; 
35003526        } 
35013527        else  if  ( optType  ===  "listOrElement" )  { 
35023528            return  isArray ( value )  ?
35033529                convertJsonOptionOfListType ( opt ,  value ,  basePath ,  errors )  :
35043530                convertJsonOption ( opt . element ,  value ,  basePath ,  errors ) ; 
35053531        } 
3506-         else  if  ( ! isString ( optType ) )  { 
3532+         else  if  ( ! isString ( opt . type ) )  { 
35073533            return  convertJsonOptionOfCustomType ( opt  as  CommandLineOptionOfCustomType ,  value  as  string ,  errors ) ; 
35083534        } 
35093535        const  validatedValue  =  validateJsonOptionValue ( opt ,  value ,  errors ) ; 
@@ -3949,6 +3975,7 @@ function getOptionValueWithEmptyStrings(value: any, option: CommandLineOption):
39493975            if  ( ! isArray ( value ) )  return  getOptionValueWithEmptyStrings ( value ,  option . element ) ; 
39503976            // fall through to list 
39513977        case  "list" :
3978+         case  "string | list" :
39523979            const  elementType  =  option . element ; 
39533980            return  isArray ( value )  ? value . map ( v  =>  getOptionValueWithEmptyStrings ( v ,  elementType ) )  : "" ; 
39543981        default :
@@ -3968,6 +3995,7 @@ function getDefaultValueForOption(option: CommandLineOption): {} {
39683995        case  "boolean" :
39693996            return  true ; 
39703997        case  "string" :
3998+         case  "string | list" :
39713999            const  defaultValue  =  option . defaultValueDescription ; 
39724000            return  option . isFilePath  ? `./${ defaultValue  &&  typeof  defaultValue  ===  "string"  ? defaultValue  : "" }  `  : "" ; 
39734001        case  "list" :
0 commit comments