-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix isSourceFileFromExternalLibrary for file with redirect #27917
Conversation
src/compiler/program.ts
Outdated
@@ -1330,7 +1330,7 @@ namespace ts { | |||
} | |||
|
|||
function isSourceFileFromExternalLibrary(file: SourceFile): boolean { | |||
return !!sourceFilesFoundSearchingNodeModules.get(file.path); | |||
return !!sourceFilesFoundSearchingNodeModules.get((file.redirectInfo ? file.redirectInfo.redirectTarget : file).path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead you should specifically set it correctly when we create redirect file. Or you also need to handle oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath)!) condition when we use program structure completely
src/compiler/program.ts
Outdated
@@ -2031,6 +2031,7 @@ namespace ts { | |||
redirect.resolvedPath = resolvedPath; | |||
redirect.originalFileName = originalFileName; | |||
redirect.redirectInfo = { redirectTarget, unredirected }; | |||
sourceFilesFoundSearchingNodeModules.set(path, !!sourceFilesFoundSearchingNodeModules.get(redirectTarget.path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This doesn't work either. You want to set it just like normal sourceFile that is with sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
otherwise you need to handle many more cases when we find sourceFile and aren't looking for currentNodeModules and set it to false. (from code
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth === 0) {
sourceFilesFoundSearchingNodeModules.set(file.path, false);
Fixes a bug where a redirecting file was never considered to be from an external library.