@@ -462,11 +462,18 @@ namespace ts {
462
462
] ;
463
463
464
464
/* @internal */
465
- export let typingOptionDeclarations : CommandLineOption [ ] = [
465
+ export let typeAcquisitionDeclarations : CommandLineOption [ ] = [
466
466
{
467
+ /* @deprecated typingOptions.enableAutoDiscovery
468
+ * Use typeAcquisition.enable instead.
469
+ */
467
470
name : "enableAutoDiscovery" ,
468
471
type : "boolean" ,
469
472
} ,
473
+ {
474
+ name : "enable" ,
475
+ type : "boolean" ,
476
+ } ,
470
477
{
471
478
name : "include" ,
472
479
type : "list" ,
@@ -501,6 +508,20 @@ namespace ts {
501
508
502
509
let optionNameMapCache : OptionNameMap ;
503
510
511
+ /* @internal */
512
+ export function convertEnableAutoDiscoveryToEnable ( typeAcquisition : TypeAcquisition ) : TypeAcquisition {
513
+ // Convert deprecated typingOptions.enableAutoDiscovery to typeAcquisition.enable
514
+ if ( typeAcquisition && typeAcquisition . enableAutoDiscovery !== undefined && typeAcquisition . enable === undefined ) {
515
+ const result : TypeAcquisition = {
516
+ enable : typeAcquisition . enableAutoDiscovery ,
517
+ include : typeAcquisition . include || [ ] ,
518
+ exclude : typeAcquisition . exclude || [ ]
519
+ } ;
520
+ return result ;
521
+ }
522
+ return typeAcquisition ;
523
+ }
524
+
504
525
/* @internal */
505
526
export function getOptionNameMap ( ) : OptionNameMap {
506
527
if ( optionNameMapCache ) {
@@ -835,15 +856,18 @@ namespace ts {
835
856
return {
836
857
options : { } ,
837
858
fileNames : [ ] ,
838
- typingOptions : { } ,
859
+ typeAcquisition : { } ,
839
860
raw : json ,
840
861
errors : [ createCompilerDiagnostic ( Diagnostics . Circularity_detected_while_resolving_configuration_Colon_0 , [ ...resolutionStack , resolvedPath ] . join ( " -> " ) ) ] ,
841
862
wildcardDirectories : { }
842
863
} ;
843
864
}
844
865
845
866
let options : CompilerOptions = convertCompilerOptionsFromJsonWorker ( json [ "compilerOptions" ] , basePath , errors , configFileName ) ;
846
- const typingOptions : TypingOptions = convertTypingOptionsFromJsonWorker ( json [ "typingOptions" ] , basePath , errors , configFileName ) ;
867
+ // typingOptions has been deprecated and is only supported for backward compatibility purposes.
868
+ // It should be removed in future releases - use typeAcquisition instead.
869
+ const jsonOptions = json [ "typeAcquisition" ] || json [ "typingOptions" ] ;
870
+ const typeAcquisition : TypeAcquisition = convertTypeAcquisitionFromJsonWorker ( jsonOptions , basePath , errors , configFileName ) ;
847
871
848
872
if ( json [ "extends" ] ) {
849
873
let [ include , exclude , files , baseOptions ] : [ string [ ] , string [ ] , string [ ] , CompilerOptions ] = [ undefined , undefined , undefined , { } ] ;
@@ -874,7 +898,7 @@ namespace ts {
874
898
return {
875
899
options,
876
900
fileNames,
877
- typingOptions ,
901
+ typeAcquisition ,
878
902
raw : json ,
879
903
errors,
880
904
wildcardDirectories,
@@ -996,9 +1020,9 @@ namespace ts {
996
1020
return { options, errors } ;
997
1021
}
998
1022
999
- export function convertTypingOptionsFromJson ( jsonOptions : any , basePath : string , configFileName ?: string ) : { options : TypingOptions , errors : Diagnostic [ ] } {
1023
+ export function convertTypeAcquisitionFromJson ( jsonOptions : any , basePath : string , configFileName ?: string ) : { options : TypeAcquisition , errors : Diagnostic [ ] } {
1000
1024
const errors : Diagnostic [ ] = [ ] ;
1001
- const options = convertTypingOptionsFromJsonWorker ( jsonOptions , basePath , errors , configFileName ) ;
1025
+ const options = convertTypeAcquisitionFromJsonWorker ( jsonOptions , basePath , errors , configFileName ) ;
1002
1026
return { options, errors } ;
1003
1027
}
1004
1028
@@ -1012,16 +1036,18 @@ namespace ts {
1012
1036
return options ;
1013
1037
}
1014
1038
1015
- function convertTypingOptionsFromJsonWorker ( jsonOptions : any ,
1016
- basePath : string , errors : Diagnostic [ ] , configFileName ?: string ) : TypingOptions {
1039
+ function convertTypeAcquisitionFromJsonWorker ( jsonOptions : any ,
1040
+ basePath : string , errors : Diagnostic [ ] , configFileName ?: string ) : TypeAcquisition {
1041
+
1042
+ const options : TypeAcquisition = { enable : getBaseFileName ( configFileName ) === "jsconfig.json" , include : [ ] , exclude : [ ] } ;
1043
+ const typeAcquisition = convertEnableAutoDiscoveryToEnable ( jsonOptions ) ;
1044
+ convertOptionsFromJson ( typeAcquisitionDeclarations , typeAcquisition , basePath , options , Diagnostics . Unknown_type_acquisition_option_0 , errors ) ;
1017
1045
1018
- const options : TypingOptions = { enableAutoDiscovery : getBaseFileName ( configFileName ) === "jsconfig.json" , include : [ ] , exclude : [ ] } ;
1019
- convertOptionsFromJson ( typingOptionDeclarations , jsonOptions , basePath , options , Diagnostics . Unknown_typing_option_0 , errors ) ;
1020
1046
return options ;
1021
1047
}
1022
1048
1023
1049
function convertOptionsFromJson ( optionDeclarations : CommandLineOption [ ] , jsonOptions : any , basePath : string ,
1024
- defaultOptions : CompilerOptions | TypingOptions , diagnosticMessage : DiagnosticMessage , errors : Diagnostic [ ] ) {
1050
+ defaultOptions : CompilerOptions | TypeAcquisition , diagnosticMessage : DiagnosticMessage , errors : Diagnostic [ ] ) {
1025
1051
1026
1052
if ( ! jsonOptions ) {
1027
1053
return ;
0 commit comments