@@ -143,7 +143,7 @@ namespace ts {
143
143
name : "out" ,
144
144
type : "string" ,
145
145
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
147
147
paramType : Diagnostics . FILE ,
148
148
} ,
149
149
{
@@ -464,7 +464,7 @@ namespace ts {
464
464
465
465
/* @internal */
466
466
export function parseCustomTypeOption ( opt : CommandLineOptionOfCustomType , value : string , errors : Diagnostic [ ] ) {
467
- const key = ( value || "" ) . trim ( ) . toLowerCase ( ) ;
467
+ const key = trimString ( ( value || "" ) ) . toLowerCase ( ) ;
468
468
const map = opt . type ;
469
469
if ( hasProperty ( map , key ) ) {
470
470
return map [ key ] ;
@@ -476,7 +476,7 @@ namespace ts {
476
476
477
477
/* @internal */
478
478
export function parseListTypeOption ( opt : CommandLineOptionOfListType , value : string , errors : Diagnostic [ ] ) : ( string | number ) [ ] {
479
- const values = ( value || "" ) . trim ( ) . split ( "," ) ;
479
+ const values = trimString ( ( value || "" ) ) . split ( "," ) ;
480
480
switch ( opt . element . type ) {
481
481
case "number" :
482
482
return ts . map ( values , parseInt ) ;
@@ -601,7 +601,7 @@ namespace ts {
601
601
* Read tsconfig.json file
602
602
* @param fileName The path to the config file
603
603
*/
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 } {
605
605
let text = "" ;
606
606
try {
607
607
text = readFile ( fileName ) ;
@@ -775,7 +775,7 @@ namespace ts {
775
775
defaultOptions : CompilerOptions | TypingOptions , diagnosticMessage : DiagnosticMessage , errors : Diagnostic [ ] ) {
776
776
777
777
if ( ! jsonOptions ) {
778
- return ;
778
+ return ;
779
779
}
780
780
781
781
const optionNameMap = arrayToMap ( optionDeclarations , opt => opt . name ) ;
@@ -829,4 +829,8 @@ namespace ts {
829
829
function convertJsonOptionOfListType ( option : CommandLineOptionOfListType , values : any [ ] , basePath : string , errors : Diagnostic [ ] ) : any [ ] {
830
830
return filter ( map ( values , v => convertJsonOption ( option . element , v , basePath , errors ) ) , v => ! ! v ) ;
831
831
}
832
+
833
+ function trimString ( s : string ) {
834
+ return typeof s . trim === "function" ? s . trim ( ) : s . replace ( / ^ [ \s ] + | [ \s ] + $ / g, "" ) ;
835
+ }
832
836
}
0 commit comments