Skip to content
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

Merged
3 commits merged into from
Oct 16, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 15, 2018

Fixes a bug where a redirecting file was never considered to be from an external library.

@@ -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);
Copy link
Member

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

@@ -2031,6 +2031,7 @@ namespace ts {
redirect.resolvedPath = resolvedPath;
redirect.originalFileName = originalFileName;
redirect.redirectInfo = { redirectTarget, unredirected };
sourceFilesFoundSearchingNodeModules.set(path, !!sourceFilesFoundSearchingNodeModules.get(redirectTarget.path));
Copy link
Member

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);

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant