@@ -255,7 +255,7 @@ namespace ts {
255
255
name : "moduleResolution" ,
256
256
type : {
257
257
"node" : ModuleResolutionKind . NodeJs ,
258
- "classic" : ModuleResolutionKind . Classic
258
+ "classic" : ModuleResolutionKind . Classic ,
259
259
} ,
260
260
description : Diagnostics . Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6 ,
261
261
error : Diagnostics . Argument_for_moduleResolution_option_must_be_node_or_classic ,
@@ -286,14 +286,40 @@ namespace ts {
286
286
description : Diagnostics . Disallow_inconsistently_cased_references_to_the_same_file
287
287
} ,
288
288
{
289
- name : "allowSyntheticDefaultImports" ,
289
+ name : "baseUrl" ,
290
+ type : "string" ,
291
+ isFilePath : true ,
292
+ description : Diagnostics . Base_directory_to_resolve_non_absolute_module_names
293
+ } ,
294
+ {
295
+ // this option can only be specified in tsconfig.json
296
+ // use type = object to copy the value as-is
297
+ name : "paths" ,
298
+ type : "object" ,
299
+ isTSConfigOnly : true
300
+ } ,
301
+ {
302
+ // this option can only be specified in tsconfig.json
303
+ // use type = object to copy the value as-is
304
+ name : "rootDirs" ,
305
+ type : "object" ,
306
+ isTSConfigOnly : true ,
307
+ isFilePath : true
308
+ } ,
309
+ {
310
+ name : "traceModuleResolution" ,
290
311
type : "boolean" ,
291
- description : Diagnostics . Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
312
+ description : Diagnostics . Enable_tracing_of_the_module_resolution_process
292
313
} ,
293
314
{
294
315
name : "allowJs" ,
295
316
type : "boolean" ,
296
317
description : Diagnostics . Allow_javascript_files_to_be_compiled
318
+ } ,
319
+ {
320
+ name : "allowSyntheticDefaultImports" ,
321
+ type : "boolean" ,
322
+ description : Diagnostics . Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
297
323
}
298
324
] ;
299
325
@@ -355,34 +381,39 @@ namespace ts {
355
381
if ( hasProperty ( optionNameMap , s ) ) {
356
382
const opt = optionNameMap [ s ] ;
357
383
358
- // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
359
- if ( ! args [ i ] && opt . type !== "boolean" ) {
360
- errors . push ( createCompilerDiagnostic ( Diagnostics . Compiler_option_0_expects_an_argument , opt . name ) ) ;
384
+ if ( opt . isTSConfigOnly ) {
385
+ errors . push ( createCompilerDiagnostic ( Diagnostics . Option_0_can_only_be_specified_in_tsconfig_json_file , opt . name ) ) ;
361
386
}
387
+ else {
388
+ // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
389
+ if ( ! args [ i ] && opt . type !== "boolean" ) {
390
+ errors . push ( createCompilerDiagnostic ( Diagnostics . Compiler_option_0_expects_an_argument , opt . name ) ) ;
391
+ }
362
392
363
- switch ( opt . type ) {
364
- case "number" :
365
- options [ opt . name ] = parseInt ( args [ i ] ) ;
366
- i ++ ;
367
- break ;
368
- case "boolean" :
369
- options [ opt . name ] = true ;
370
- break ;
371
- case "string" :
372
- options [ opt . name ] = args [ i ] || "" ;
373
- i ++ ;
374
- break ;
375
- // If not a primitive, the possible types are specified in what is effectively a map of options.
376
- default :
377
- let map = < Map < number > > opt . type ;
378
- let key = ( args [ i ] || "" ) . toLowerCase ( ) ;
379
- i ++ ;
380
- if ( hasProperty ( map , key ) ) {
381
- options [ opt . name ] = map [ key ] ;
382
- }
383
- else {
384
- errors . push ( createCompilerDiagnostic ( ( < CommandLineOptionOfCustomType > opt ) . error ) ) ;
385
- }
393
+ switch ( opt . type ) {
394
+ case "number" :
395
+ options [ opt . name ] = parseInt ( args [ i ] ) ;
396
+ i ++ ;
397
+ break ;
398
+ case "boolean" :
399
+ options [ opt . name ] = true ;
400
+ break ;
401
+ case "string" :
402
+ options [ opt . name ] = args [ i ] || "" ;
403
+ i ++ ;
404
+ break ;
405
+ // If not a primitive, the possible types are specified in what is effectively a map of options.
406
+ default :
407
+ let map = < Map < number > > opt . type ;
408
+ let key = ( args [ i ] || "" ) . toLowerCase ( ) ;
409
+ i ++ ;
410
+ if ( hasProperty ( map , key ) ) {
411
+ options [ opt . name ] = map [ key ] ;
412
+ }
413
+ else {
414
+ errors . push ( createCompilerDiagnostic ( ( < CommandLineOptionOfCustomType > opt ) . error ) ) ;
415
+ }
416
+ }
386
417
}
387
418
}
388
419
else {
@@ -485,7 +516,6 @@ namespace ts {
485
516
return output ;
486
517
}
487
518
488
-
489
519
/**
490
520
* Parse the contents of a config file (tsconfig.json).
491
521
* @param json The contents of the config file to parse
@@ -497,6 +527,7 @@ namespace ts {
497
527
const { options : optionsFromJsonConfigFile , errors } = convertCompilerOptionsFromJson ( json [ "compilerOptions" ] , basePath , configFileName ) ;
498
528
499
529
const options = extend ( existingOptions , optionsFromJsonConfigFile ) ;
530
+
500
531
return {
501
532
options,
502
533
fileNames : getFileNames ( ) ,
@@ -580,7 +611,36 @@ namespace ts {
580
611
}
581
612
}
582
613
if ( opt . isFilePath ) {
583
- value = normalizePath ( combinePaths ( basePath , value ) ) ;
614
+ switch ( typeof value ) {
615
+ case "string" :
616
+ value = normalizePath ( combinePaths ( basePath , value ) ) ;
617
+ break ;
618
+ case "object" :
619
+ // "object" options with 'isFilePath' = true expected to be string arrays
620
+ let paths : string [ ] = [ ] ;
621
+ let invalidOptionType = false ;
622
+ if ( ! isArray ( value ) ) {
623
+ invalidOptionType = true ;
624
+ }
625
+ else {
626
+ for ( const element of < any [ ] > value ) {
627
+ if ( typeof element === "string" ) {
628
+ paths . push ( normalizePath ( combinePaths ( basePath , element ) ) ) ;
629
+ }
630
+ else {
631
+ invalidOptionType = true ;
632
+ break ;
633
+ }
634
+ }
635
+ }
636
+ if ( invalidOptionType ) {
637
+ errors . push ( createCompilerDiagnostic ( Diagnostics . Option_0_should_have_array_of_strings_as_a_value , opt . name ) ) ;
638
+ }
639
+ else {
640
+ value = paths ;
641
+ }
642
+ break ;
643
+ }
584
644
if ( value === "" ) {
585
645
value = "." ;
586
646
}
0 commit comments