@@ -143,7 +143,7 @@ namespace ts {
143143 name : "out" ,
144144 type : "string" ,
145145 isFilePath : false , // This is intentionally broken to support compatability with existing tsconfig files
146- // for correct behaviour, please use outFile
146+ // for correct behaviour, please use outFile
147147 paramType : Diagnostics . FILE ,
148148 } ,
149149 {
@@ -464,7 +464,7 @@ namespace ts {
464464
465465 /* @internal */
466466 export function parseCustomTypeOption ( opt : CommandLineOptionOfCustomType , value : string , errors : Diagnostic [ ] ) {
467- const key = ( value || "" ) . trim ( ) . toLowerCase ( ) ;
467+ const key = trimString ( ( value || "" ) ) . toLowerCase ( ) ;
468468 const map = opt . type ;
469469 if ( hasProperty ( map , key ) ) {
470470 return map [ key ] ;
@@ -476,7 +476,7 @@ namespace ts {
476476
477477 /* @internal */
478478 export function parseListTypeOption ( opt : CommandLineOptionOfListType , value : string , errors : Diagnostic [ ] ) : ( string | number ) [ ] {
479- const values = ( value || "" ) . trim ( ) . split ( "," ) ;
479+ const values = trimString ( ( value || "" ) ) . split ( "," ) ;
480480 switch ( opt . element . type ) {
481481 case "number" :
482482 return ts . map ( values , parseInt ) ;
@@ -601,7 +601,7 @@ namespace ts {
601601 * Read tsconfig.json file
602602 * @param fileName The path to the config file
603603 */
604- export function readConfigFile ( fileName : string , readFile : ( path : string ) => string ) : { config ?: any ; error ?: Diagnostic } {
604+ export function readConfigFile ( fileName : string , readFile : ( path : string ) => string ) : { config ?: any ; error ?: Diagnostic } {
605605 let text = "" ;
606606 try {
607607 text = readFile ( fileName ) ;
@@ -775,7 +775,7 @@ namespace ts {
775775 defaultOptions : CompilerOptions | TypingOptions , diagnosticMessage : DiagnosticMessage , errors : Diagnostic [ ] ) {
776776
777777 if ( ! jsonOptions ) {
778- return ;
778+ return ;
779779 }
780780
781781 const optionNameMap = arrayToMap ( optionDeclarations , opt => opt . name ) ;
@@ -829,4 +829,8 @@ namespace ts {
829829 function convertJsonOptionOfListType ( option : CommandLineOptionOfListType , values : any [ ] , basePath : string , errors : Diagnostic [ ] ) : any [ ] {
830830 return filter ( map ( values , v => convertJsonOption ( option . element , v , basePath , errors ) ) , v => ! ! v ) ;
831831 }
832+
833+ function trimString ( s : string ) {
834+ return typeof s . trim === "function" ? s . trim ( ) : s . replace ( / ^ [ \s ] + | [ \s ] + $ / g, "" ) ;
835+ }
832836}
0 commit comments