@@ -113,10 +113,16 @@ func processAllProgramFiles(
113
113
var unsupportedExtensions []string
114
114
115
115
loader .parseTasks .collect (& loader , loader .rootTasks , func (task * parseTask , _ []tspath.Path ) {
116
- file := task .file
117
116
if task .isRedirected {
118
117
return
119
118
}
119
+
120
+ if task .isForAutomaticTypeDirective {
121
+ typeResolutionsInFile [task .path ] = task .typeResolutionsInFile
122
+ return
123
+ }
124
+ file := task .file
125
+ path := task .path
120
126
if file == nil {
121
127
missingFiles = append (missingFiles , task .normalizedFilePath )
122
128
return
@@ -126,7 +132,6 @@ func processAllProgramFiles(
126
132
} else {
127
133
files = append (files , file )
128
134
}
129
- path := file .Path ()
130
135
131
136
filesByPath [path ] = file
132
137
resolvedModules [path ] = task .resolutionsInFile
@@ -189,14 +194,31 @@ func (p *fileLoader) addAutomaticTypeDirectiveTasks() {
189
194
containingDirectory = p .opts .Host .GetCurrentDirectory ()
190
195
}
191
196
containingFileName := tspath .CombinePaths (containingDirectory , module .InferredTypesContainingFile )
197
+ p .rootTasks = append (p .rootTasks , & parseTask {normalizedFilePath : containingFileName , isLib : false , isForAutomaticTypeDirective : true })
198
+ }
192
199
193
- automaticTypeDirectiveNames := module .GetAutomaticTypeDirectiveNames (compilerOptions , p .opts .Host )
194
- for _ , name := range automaticTypeDirectiveNames {
195
- resolved := p .resolver .ResolveTypeReferenceDirective (name , containingFileName , core .ModuleKindNodeNext , nil )
196
- if resolved .IsResolved () {
197
- p .rootTasks = append (p .rootTasks , & parseTask {normalizedFilePath : resolved .ResolvedFileName , isLib : false })
200
+ func (p * fileLoader ) resolveAutomaticTypeDirectives (containingFileName string ) (
201
+ toParse []resolvedRef ,
202
+ typeResolutionsInFile module.ModeAwareCache [* module.ResolvedTypeReferenceDirective ],
203
+ ) {
204
+ automaticTypeDirectiveNames := module .GetAutomaticTypeDirectiveNames (p .opts .Config .CompilerOptions (), p .opts .Host )
205
+ if len (automaticTypeDirectiveNames ) != 0 {
206
+ toParse = make ([]resolvedRef , 0 , len (automaticTypeDirectiveNames ))
207
+ typeResolutionsInFile = make (module.ModeAwareCache [* module.ResolvedTypeReferenceDirective ], len (automaticTypeDirectiveNames ))
208
+ for _ , name := range automaticTypeDirectiveNames {
209
+ resolutionMode := core .ModuleKindNodeNext
210
+ resolved := p .resolver .ResolveTypeReferenceDirective (name , containingFileName , resolutionMode , nil )
211
+ typeResolutionsInFile [module.ModeAwareCacheKey {Name : name , Mode : resolutionMode }] = resolved
212
+ if resolved .IsResolved () {
213
+ toParse = append (toParse , resolvedRef {
214
+ fileName : resolved .ResolvedFileName ,
215
+ increaseDepth : resolved .IsExternalLibraryImport ,
216
+ elideOnDepth : false ,
217
+ })
218
+ }
198
219
}
199
220
}
221
+ return toParse , typeResolutionsInFile
200
222
}
201
223
202
224
func (p * fileLoader ) addProjectReferenceTasks () {
0 commit comments