@@ -57,6 +57,8 @@ var tsconfigRootOptionsMap = &CommandLineOption{
5757 Kind : CommandLineOptionTypeObject ,
5858 ElementOptions : commandLineOptionsToMap ([]* CommandLineOption {
5959 compilerOptionsDeclaration ,
60+ // watchOptionsDeclaration,
61+ typeAcquisitionDeclaration ,
6062 extendsOptionDeclaration ,
6163 {
6264 Name : "references" ,
@@ -107,8 +109,8 @@ type ExtendedConfigCacheEntry struct {
107109type parsedTsconfig struct {
108110 raw any
109111 options * core.CompilerOptions
110- // watchOptions *compiler .WatchOptions
111- // typeAcquisition *compiler .TypeAcquisition
112+ // watchOptions *core .WatchOptions
113+ typeAcquisition * core .TypeAcquisition
112114 // Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet
113115 extendedConfigPath any
114116}
@@ -119,8 +121,8 @@ func parseOwnConfigOfJsonSourceFile(
119121 basePath string ,
120122 configFileName string ,
121123) (* parsedTsconfig , []* ast.Diagnostic ) {
122- options := getDefaultCompilerOptions (configFileName )
123- // var typeAcquisition *compiler.TypeAcquisition
124+ compilerOptions := getDefaultCompilerOptions (configFileName )
125+ typeAcquisition := getDefaultTypeAcquisition ( configFileName )
124126 // var watchOptions *compiler.WatchOptions
125127 var extendedConfigPath any
126128 var rootCompilerOptions []* ast.PropertyName
@@ -139,7 +141,14 @@ func parseOwnConfigOfJsonSourceFile(
139141 }
140142 if parentOption != nil && parentOption .Name != "undefined" && value != nil {
141143 if option != nil && option .Name != "" {
142- propertySetErrors = append (propertySetErrors , ParseCompilerOptions (option .Name , value , options )... )
144+ var parseDiagnostics []* ast.Diagnostic
145+ switch parentOption .Name {
146+ case "compilerOptions" :
147+ parseDiagnostics = ParseCompilerOptions (option .Name , value , compilerOptions )
148+ case "typeAcquisition" :
149+ parseDiagnostics = ParseTypeAcquisition (option .Name , value , typeAcquisition )
150+ }
151+ propertySetErrors = append (propertySetErrors , parseDiagnostics ... )
143152 } else if keyText != "" {
144153 if parentOption .ElementOptions != nil {
145154 // !!! TODO: support suggestion
@@ -178,9 +187,9 @@ func parseOwnConfigOfJsonSourceFile(
178187 // }
179188 return & parsedTsconfig {
180189 raw : json ,
181- options : options ,
190+ options : compilerOptions ,
182191 // watchOptions: watchOptions,
183- // typeAcquisition: typeAcquisition,
192+ typeAcquisition : typeAcquisition ,
184193 extendedConfigPath : extendedConfigPath ,
185194 }, errors
186195}
@@ -479,19 +488,19 @@ type tsConfigOptions struct {
479488 notDefined string
480489}
481490
482- func commandLineOptionsToMap (options []* CommandLineOption ) map [string ]* CommandLineOption {
491+ func commandLineOptionsToMap (compilerOptions []* CommandLineOption ) map [string ]* CommandLineOption {
483492 result := make (map [string ]* CommandLineOption )
484- for i := range options {
485- result [(options [i ]).Name ] = options [i ]
493+ for i := range compilerOptions {
494+ result [(compilerOptions [i ]).Name ] = compilerOptions [i ]
486495 }
487496 return result
488497}
489498
490499var commandLineCompilerOptionsMap map [string ]* CommandLineOption = commandLineOptionsToMap (OptionsDeclarations )
491500
492- func convertMapToOptions [O optionParser ](options * collections.OrderedMap [string , any ], result O ) O {
501+ func convertMapToOptions [O optionParser ](compilerOptions * collections.OrderedMap [string , any ], result O ) O {
493502 // this assumes any `key`, `value` pair in `options` will have `value` already be the correct type. this function should no error handling
494- for key , value := range options .Entries () {
503+ for key , value := range compilerOptions .Entries () {
495504 result .ParseOption (key , value )
496505 }
497506 return result
@@ -758,6 +767,14 @@ func getDefaultCompilerOptions(configFileName string) *core.CompilerOptions {
758767 return options
759768}
760769
770+ func getDefaultTypeAcquisition (configFileName string ) * core.TypeAcquisition {
771+ options := & core.TypeAcquisition {}
772+ if configFileName != "" && tspath .GetBaseFileName (configFileName ) == "jsconfig.json" {
773+ options .Enable = core .TSTrue
774+ }
775+ return options
776+ }
777+
761778func convertCompilerOptionsFromJsonWorker (jsonOptions any , basePath string , configFileName string ) (* core.CompilerOptions , []* ast.Diagnostic ) {
762779 options := getDefaultCompilerOptions (configFileName )
763780 _ , errors := convertOptionsFromJson (commandLineCompilerOptionsMap , jsonOptions , basePath , & compilerOptionsParser {options })
@@ -767,6 +784,12 @@ func convertCompilerOptionsFromJsonWorker(jsonOptions any, basePath string, conf
767784 return options , errors
768785}
769786
787+ func convertTypeAcquisitionFromJsonWorker (jsonOptions any , basePath string , configFileName string ) (* core.TypeAcquisition , []* ast.Diagnostic ) {
788+ options := getDefaultTypeAcquisition (configFileName )
789+ _ , errors := convertOptionsFromJson (typeAcquisitionDeclaration .ElementOptions , jsonOptions , basePath , & typeAcquisitionParser {options })
790+ return options , errors
791+ }
792+
770793func parseOwnConfigOfJson (
771794 json * collections.OrderedMap [string , any ],
772795 host ParseConfigHost ,
@@ -778,8 +801,8 @@ func parseOwnConfigOfJson(
778801 errors = append (errors , ast .NewCompilerDiagnostic (diagnostics .Unknown_option_excludes_Did_you_mean_exclude ))
779802 }
780803 options , err := convertCompilerOptionsFromJsonWorker (json .GetOrZero ("compilerOptions" ), basePath , configFileName )
781- errors = append ( errors , err ... )
782- // typeAcquisition := convertTypeAcquisitionFromJsonWorker(json.typeAcquisition, basePath, errors, configFileName )
804+ typeAcquisition , err2 := convertTypeAcquisitionFromJsonWorker ( json . GetOrZero ( "typeAcquisition" ), basePath , configFileName )
805+ errors = append ( append ( errors , err ... ), err2 ... )
783806 // watchOptions := convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors)
784807 // json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors)
785808 var extendedConfigPath []string
@@ -790,6 +813,7 @@ func parseOwnConfigOfJson(
790813 parsedConfig := & parsedTsconfig {
791814 raw : json ,
792815 options : options ,
816+ typeAcquisition : typeAcquisition ,
793817 extendedConfigPath : extendedConfigPath ,
794818 }
795819 return parsedConfig , errors
@@ -1176,7 +1200,9 @@ func parseJsonConfigFileContentWorker(
11761200
11771201 return & ParsedCommandLine {
11781202 ParsedConfig : & core.ParsedOptions {
1179- CompilerOptions : parsedConfig .options ,
1203+ CompilerOptions : parsedConfig .options ,
1204+ TypeAcquisition : parsedConfig .typeAcquisition ,
1205+ // WatchOptions: nil,
11801206 FileNames : getFileNames (basePathForFileNames ),
11811207 ProjectReferences : getProjectReferences (basePathForFileNames ),
11821208 },
@@ -1321,43 +1347,43 @@ func substituteStringArrayWithConfigDirTemplate(list []string, basePath string)
13211347 }
13221348}
13231349
1324- func handleOptionConfigDirTemplateSubstitution (options * core.CompilerOptions , basePath string ) {
1325- if options == nil {
1350+ func handleOptionConfigDirTemplateSubstitution (compilerOptions * core.CompilerOptions , basePath string ) {
1351+ if compilerOptions == nil {
13261352 return
13271353 }
13281354
13291355 // !!! don't hardcode this; use options declarations?
13301356
1331- for v := range options .Paths .Values () {
1357+ for v := range compilerOptions .Paths .Values () {
13321358 substituteStringArrayWithConfigDirTemplate (v , basePath )
13331359 }
13341360
1335- substituteStringArrayWithConfigDirTemplate (options .RootDirs , basePath )
1336- substituteStringArrayWithConfigDirTemplate (options .TypeRoots , basePath )
1361+ substituteStringArrayWithConfigDirTemplate (compilerOptions .RootDirs , basePath )
1362+ substituteStringArrayWithConfigDirTemplate (compilerOptions .TypeRoots , basePath )
13371363
1338- if startsWithConfigDirTemplate (options .GenerateCpuProfile ) {
1339- options .GenerateCpuProfile = getSubstitutedPathWithConfigDirTemplate (options .GenerateCpuProfile , basePath )
1364+ if startsWithConfigDirTemplate (compilerOptions .GenerateCpuProfile ) {
1365+ compilerOptions .GenerateCpuProfile = getSubstitutedPathWithConfigDirTemplate (compilerOptions .GenerateCpuProfile , basePath )
13401366 }
1341- if startsWithConfigDirTemplate (options .GenerateTrace ) {
1342- options .GenerateTrace = getSubstitutedPathWithConfigDirTemplate (options .GenerateTrace , basePath )
1367+ if startsWithConfigDirTemplate (compilerOptions .GenerateTrace ) {
1368+ compilerOptions .GenerateTrace = getSubstitutedPathWithConfigDirTemplate (compilerOptions .GenerateTrace , basePath )
13431369 }
1344- if startsWithConfigDirTemplate (options .OutFile ) {
1345- options .OutFile = getSubstitutedPathWithConfigDirTemplate (options .OutFile , basePath )
1370+ if startsWithConfigDirTemplate (compilerOptions .OutFile ) {
1371+ compilerOptions .OutFile = getSubstitutedPathWithConfigDirTemplate (compilerOptions .OutFile , basePath )
13461372 }
1347- if startsWithConfigDirTemplate (options .OutDir ) {
1348- options .OutDir = getSubstitutedPathWithConfigDirTemplate (options .OutDir , basePath )
1373+ if startsWithConfigDirTemplate (compilerOptions .OutDir ) {
1374+ compilerOptions .OutDir = getSubstitutedPathWithConfigDirTemplate (compilerOptions .OutDir , basePath )
13491375 }
1350- if startsWithConfigDirTemplate (options .RootDir ) {
1351- options .RootDir = getSubstitutedPathWithConfigDirTemplate (options .RootDir , basePath )
1376+ if startsWithConfigDirTemplate (compilerOptions .RootDir ) {
1377+ compilerOptions .RootDir = getSubstitutedPathWithConfigDirTemplate (compilerOptions .RootDir , basePath )
13521378 }
1353- if startsWithConfigDirTemplate (options .TsBuildInfoFile ) {
1354- options .TsBuildInfoFile = getSubstitutedPathWithConfigDirTemplate (options .TsBuildInfoFile , basePath )
1379+ if startsWithConfigDirTemplate (compilerOptions .TsBuildInfoFile ) {
1380+ compilerOptions .TsBuildInfoFile = getSubstitutedPathWithConfigDirTemplate (compilerOptions .TsBuildInfoFile , basePath )
13551381 }
1356- if startsWithConfigDirTemplate (options .BaseUrl ) {
1357- options .BaseUrl = getSubstitutedPathWithConfigDirTemplate (options .BaseUrl , basePath )
1382+ if startsWithConfigDirTemplate (compilerOptions .BaseUrl ) {
1383+ compilerOptions .BaseUrl = getSubstitutedPathWithConfigDirTemplate (compilerOptions .BaseUrl , basePath )
13581384 }
1359- if startsWithConfigDirTemplate (options .DeclarationDir ) {
1360- options .DeclarationDir = getSubstitutedPathWithConfigDirTemplate (options .DeclarationDir , basePath )
1385+ if startsWithConfigDirTemplate (compilerOptions .DeclarationDir ) {
1386+ compilerOptions .DeclarationDir = getSubstitutedPathWithConfigDirTemplate (compilerOptions .DeclarationDir , basePath )
13611387 }
13621388}
13631389
@@ -1517,8 +1543,8 @@ func getFileNamesFromConfigSpecs(
15171543 return files
15181544}
15191545
1520- func GetSupportedExtensions (options * core.CompilerOptions , extraFileExtensions []fileExtensionInfo ) [][]string {
1521- needJSExtensions := options .GetAllowJS ()
1546+ func GetSupportedExtensions (compilerOptions * core.CompilerOptions , extraFileExtensions []fileExtensionInfo ) [][]string {
1547+ needJSExtensions := compilerOptions .GetAllowJS ()
15221548 if len (extraFileExtensions ) == 0 {
15231549 if needJSExtensions {
15241550 return tspath .AllSupportedExtensions
@@ -1543,8 +1569,8 @@ func GetSupportedExtensions(options *core.CompilerOptions, extraFileExtensions [
15431569 return extensions
15441570}
15451571
1546- func GetSupportedExtensionsWithJsonIfResolveJsonModule (options * core.CompilerOptions , supportedExtensions [][]string ) [][]string {
1547- if options == nil || ! options .GetResolveJsonModule () {
1572+ func GetSupportedExtensionsWithJsonIfResolveJsonModule (compilerOptions * core.CompilerOptions , supportedExtensions [][]string ) [][]string {
1573+ if compilerOptions == nil || ! compilerOptions .GetResolveJsonModule () {
15481574 return supportedExtensions
15491575 }
15501576 if core .Same (supportedExtensions , tspath .AllSupportedExtensions ) {
0 commit comments