@@ -248,6 +248,7 @@ namespace ts {
248
248
perDirectoryCacheWithRedirects : CacheWithRedirects < Map < T > > ,
249
249
loader : ( name : string , containingFile : string , options : CompilerOptions , host : ModuleResolutionHost , redirectedReference ?: ResolvedProjectReference ) => T ,
250
250
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
251
+ shouldRetryResolution : ( t : T ) => boolean ,
251
252
reusedNames : ReadonlyArray < string > | undefined ,
252
253
logChanges : boolean ) : ( R | undefined ) [ ] {
253
254
@@ -260,7 +261,7 @@ namespace ts {
260
261
perDirectoryResolution = createMap ( ) ;
261
262
perDirectoryCache . set ( dirPath , perDirectoryResolution ) ;
262
263
}
263
- const resolvedModules : R [ ] = [ ] ;
264
+ const resolvedModules : ( R | undefined ) [ ] = [ ] ;
264
265
const compilerOptions = resolutionHost . getCompilationSettings ( ) ;
265
266
const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports ( path ) ;
266
267
@@ -278,7 +279,7 @@ namespace ts {
278
279
if ( ! seenNamesInFile . has ( name ) &&
279
280
allFilesHaveInvalidatedResolution || unmatchedRedirects || ! resolution || resolution . isInvalidated ||
280
281
// If the name is unresolved import that was invalidated, recalculate
281
- ( hasInvalidatedNonRelativeUnresolvedImport && ! isExternalModuleNameRelative ( name ) && ! getResolutionWithResolvedFileName ( resolution ) ) ) {
282
+ ( hasInvalidatedNonRelativeUnresolvedImport && ! isExternalModuleNameRelative ( name ) && shouldRetryResolution ( resolution ) ) ) {
282
283
const existingResolution = resolution ;
283
284
const resolutionInDirectory = perDirectoryResolution . get ( name ) ;
284
285
if ( resolutionInDirectory ) {
@@ -302,7 +303,7 @@ namespace ts {
302
303
}
303
304
Debug . assert ( resolution !== undefined && ! resolution . isInvalidated ) ;
304
305
seenNamesInFile . set ( name , true ) ;
305
- resolvedModules . push ( getResolutionWithResolvedFileName ( resolution ) ! ) ; // TODO: GH#18217
306
+ resolvedModules . push ( getResolutionWithResolvedFileName ( resolution ) ) ;
306
307
}
307
308
308
309
// Stop watching and remove the unused name
@@ -339,6 +340,7 @@ namespace ts {
339
340
typeDirectiveNames , containingFile , redirectedReference ,
340
341
resolvedTypeReferenceDirectives , perDirectoryResolvedTypeReferenceDirectives ,
341
342
resolveTypeReferenceDirective , getResolvedTypeReferenceDirective ,
343
+ /*shouldRetryResolution*/ resolution => resolution . resolvedTypeReferenceDirective === undefined ,
342
344
/*reusedNames*/ undefined , /*logChanges*/ false
343
345
) ;
344
346
}
@@ -348,6 +350,7 @@ namespace ts {
348
350
moduleNames , containingFile , redirectedReference ,
349
351
resolvedModuleNames , perDirectoryResolvedModuleNames ,
350
352
resolveModuleName , getResolvedModule ,
353
+ /*shouldRetryResolution*/ resolution => ! resolution . resolvedModule || ! resolutionExtensionIsTSOrJson ( resolution . resolvedModule . extension ) ,
351
354
reusedNames , logChangesWhenResolvingModule
352
355
) ;
353
356
}
0 commit comments