Skip to content

Strip "/index" from import fix module specifiers #19962

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

Merged
3 commits merged into from
Nov 16, 2017

Conversation

ghost
Copy link

@ghost ghost commented Nov 13, 2017

Fixes #19957

@@ -322,7 +322,7 @@ namespace ts.codefix {
tryGetModuleNameAsNodeModule(options, moduleFileName, host, getCanonicalFileName, sourceDirectory) ||
tryGetModuleNameFromBaseUrl(options, moduleFileName, getCanonicalFileName) ||
options.rootDirs && tryGetModuleNameFromRootDirs(options.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) ||
removeFileExtension(getRelativePath(moduleFileName, sourceDirectory, getCanonicalFileName));
removeExtensionAndIndexPostFix(getRelativePath(moduleFileName, sourceDirectory, getCanonicalFileName));
Copy link
Member

Choose a reason for hiding this comment

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

You shouldnt be removing file index when module resolution is not node_modules right? Because classicModuleResolver doesnt auto lookup for file with name of index in moduleName directory?

@sheetalkamat
Copy link
Member

Needs test case for classic node resolver for

  • when it has node_modules folder and contains index file and its not part of the import fix
  • normal case where the import fix is suggested correctly

@ghost ghost force-pushed the importNameCodeFixNewImportIndex branch from 1b4d504 to 30dad34 Compare November 16, 2017 16:32
@ghost ghost merged commit 94581c1 into master Nov 16, 2017
@ghost ghost deleted the importNameCodeFixNewImportIndex branch November 16, 2017 19:12
@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