@@ -213,7 +213,7 @@ namespace ts.moduleSpecifiers {
213
213
}
214
214
215
215
export function forEachFileNameOfModule < T > (
216
- importingFileName : string ,
216
+ _importingFileName : string ,
217
217
importedFileName : string ,
218
218
host : ModuleSpecifierResolutionHost ,
219
219
preferSymlinks : boolean ,
@@ -233,27 +233,23 @@ namespace ts.moduleSpecifiers {
233
233
? host . getSymlinkCache ( )
234
234
: discoverProbableSymlinks ( host . getSourceFiles ( ) , getCanonicalFileName , cwd ) ;
235
235
236
- const symlinkedDirectories = links . getSymlinkedDirectories ( ) ;
237
236
const useCaseSensitiveFileNames = ! host . useCaseSensitiveFileNames || host . useCaseSensitiveFileNames ( ) ;
238
- const result = symlinkedDirectories && forEachEntry ( symlinkedDirectories , ( resolved , path ) => {
239
- if ( resolved === false ) return undefined ;
240
- if ( startsWithDirectory ( importingFileName , resolved . realPath , getCanonicalFileName ) ) {
241
- return undefined ; // Don't want to a package to globally import from itself
242
- }
243
-
237
+ const realPathToSymlinks = links . getRealPathToSymlinks ( ) ;
238
+ const result = realPathToSymlinks && forEachEntry ( realPathToSymlinks , ( paths , resolved ) => {
244
239
return forEach ( targets , target => {
245
- if ( ! containsPath ( resolved . real , target , ! useCaseSensitiveFileNames ) ) {
240
+ if ( ! containsPath ( resolved , target , ! useCaseSensitiveFileNames ) ) {
246
241
return ;
247
242
}
248
243
249
- const relative = getRelativePathFromDirectory ( resolved . real , target , getCanonicalFileName ) ;
250
- const option = resolvePath ( path , relative ) ;
251
- if ( ! host . fileExists || host . fileExists ( option ) ) {
244
+ const relative = getRelativePathFromDirectory ( resolved , target , getCanonicalFileName ) ;
245
+ for ( const path of paths ) {
246
+ const option = resolvePath ( path , relative ) ;
252
247
const result = cb ( option , target === referenceRedirect ) ;
253
248
if ( result ) return result ;
254
249
}
255
250
} ) ;
256
251
} ) ;
252
+
257
253
return result ||
258
254
( preferSymlinks ? forEach ( targets , p => cb ( p , p === referenceRedirect ) ) : undefined ) ;
259
255
}
0 commit comments