@@ -151,7 +151,7 @@ namespace ts {
151
151
const toImport = oldFromNew !== undefined
152
152
// If we're at the new location (file was already renamed), need to redo module resolution starting from the old location.
153
153
// TODO:GH#18217
154
- ? getSourceFileToImportFromResolved ( resolveModuleName ( importLiteral . text , oldImportFromPath , program . getCompilerOptions ( ) , host as ModuleResolutionHost ) ,
154
+ ? getSourceFileToImportFromResolved ( importLiteral , resolveModuleName ( importLiteral . text , oldImportFromPath , program . getCompilerOptions ( ) , host as ModuleResolutionHost ) ,
155
155
oldToNew , allFiles )
156
156
: getSourceFileToImport ( importedModuleSymbol , importLiteral , sourceFile , program , host , oldToNew ) ;
157
157
@@ -193,11 +193,11 @@ namespace ts {
193
193
const resolved = host . resolveModuleNames
194
194
? host . getResolvedModuleWithFailedLookupLocationsFromCache && host . getResolvedModuleWithFailedLookupLocationsFromCache ( importLiteral . text , importingSourceFile . fileName )
195
195
: program . getResolvedModuleWithFailedLookupLocationsFromCache ( importLiteral . text , importingSourceFile . fileName ) ;
196
- return getSourceFileToImportFromResolved ( resolved , oldToNew , program . getSourceFiles ( ) ) ;
196
+ return getSourceFileToImportFromResolved ( importLiteral , resolved , oldToNew , program . getSourceFiles ( ) ) ;
197
197
}
198
198
}
199
199
200
- function getSourceFileToImportFromResolved ( resolved : ResolvedModuleWithFailedLookupLocations | undefined , oldToNew : PathUpdater , sourceFiles : readonly SourceFile [ ] ) : ToImport | undefined {
200
+ function getSourceFileToImportFromResolved ( importLiteral : StringLiteralLike , resolved : ResolvedModuleWithFailedLookupLocations | undefined , oldToNew : PathUpdater , sourceFiles : readonly SourceFile [ ] ) : ToImport | undefined {
201
201
// Search through all locations looking for a moved file, and only then test already existing files.
202
202
// This is because if `a.ts` is compiled to `a.js` and `a.ts` is moved, we don't want to resolve anything to `a.js`, but to `a.ts`'s new location.
203
203
if ( ! resolved ) return undefined ;
@@ -210,8 +210,9 @@ namespace ts {
210
210
211
211
// Then failed lookups that are in the list of sources
212
212
const result = forEach ( resolved . failedLookupLocations , tryChangeWithIgnoringPackageJsonExisting )
213
- // Then failed lookups except package.json since we dont want to touch them (only included ts/js files)
214
- || forEach ( resolved . failedLookupLocations , tryChangeWithIgnoringPackageJson ) ;
213
+ // Then failed lookups except package.json since we dont want to touch them (only included ts/js files).
214
+ // At this point, the confidence level of this fix being correct is too low to change bare specifiers or absolute paths.
215
+ || pathIsRelative ( importLiteral . text ) && forEach ( resolved . failedLookupLocations , tryChangeWithIgnoringPackageJson ) ;
215
216
if ( result ) return result ;
216
217
217
218
// If nothing changed, then result is resolved module file thats not updated
0 commit comments