Skip to content

With classic resolution, don't provide import for a location inside node_modules #20371

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

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 30, 2017

Fixes #20050

@ghost ghost force-pushed the importCodeFix_noClassic branch from b82c25e to dffcabb Compare November 30, 2017 17:55
@ghost ghost requested a review from sheetalkamat November 30, 2017 17:55
return [relativePath];
// Don't use a relative path that would pass through node_modules -- should have handled that that in `tryGetModuleNameAsNodeModule`,
// but would do nothing there if we're in classic resolution, so return no result in that case.
return forEachAncestorDirectory(relativePath, p => getBaseFileName(p) === "node_modules" ? true : undefined) ? [] : [relativePath];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just check module resolution strategy is classic resolver when doing this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, now I'm thinking we shouldn't do anything here.
We're providing an import fix for that file because the file has already been included in the project. In the case of this test, that's because fourslash adds all the files to the language service. In a real scenario that would only happen if the file had already been imported somehow.
So I think it would suffice to just test that the import fix is for a relative path and not a global import. Does that sound right?

@ghost
Copy link
Author

ghost commented Dec 4, 2017

Closing in favor of #20453.

@ghost ghost closed this Dec 4, 2017
@ghost ghost deleted the importCodeFix_noClassic branch December 4, 2017 21:16
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant