-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Canonicalize path before calling startsWith
#25364
Conversation
I do agree with Daniel that we probably should err on adding more test coverage tho, considering this is used for paths in declaration emit now, too. |
@@ -290,7 +290,7 @@ namespace ts.moduleSpecifiers { | |||
const moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); | |||
// Get a path that's relative to node_modules or the importing file's path | |||
// if node_modules folder is in this folder or any of its parent folders, no need to keep it. | |||
if (!startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) return undefined; | |||
if (!startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; |
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.
Dont you need to do getCanonicalFileName for sourceDirectory as well?
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.
That comes from importingSourceFile.path
which should already be canonicalized.
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.
Makes sense. Good that you changed the type there so its easy to catch in future. Thanks.
Also looks related to #25338 |
@sheetalkamat Do we have any existing case-insensitivity tests? I thought fourslash was case-insensitive but I can't reproduce the error in a fourslash test. |
you can add it in tsserver unit tests where default host is case insensitive |
Figured out why fourslash test wasn't working, I needed to put a capitalized name before the importing directory. |
I'm running vscode 1.25.0 and typscript 2.9.2, still have this issue. Can anyone help? Thanks |
|
This is all cool, but angular cli does not allow to use the newest typescript. What should we do? |
@smnbbrv Just install typescript globally with |
@andy-ms thanks, it works! |
@ratidzidziguri can you share more info. |
solution for now was to only set VsCode to use workplace TS version. In my case that is the one installed with angular and it is 2.7.2 |
Maybe I say bullshit but if the typescript version is so crucial why don’t you guys just bundle it with vscode or at least give users some hint about mismatching typescript versions and the consequences of that? The way how it is done right now is so counter intuitive; it was properly working one version before, then it gets broken and the only way to fix this is using beta versions of typescript; that’s kinda... weird |
The next version of VSCode should include the fix. VSCode insiders tomorrow should include the fix. If you are on latest VSCode and want to try the fix out, you can find instructions on using a custom version of TS in your VSCode at: Using Newer TypeScript Versions. |
@andy-ms I just installed the latest insiders and am on TS 2.9.2 - you mentioned the new insiders should have the fix - should 2.9.2 + latest insiders be working? I'm still getting the same behavior as when I originally opened the issue. |
☝️ never mind, it does work when I update to @next. So for those dealing with this issue that aren't using insiders and tsnext, will they have to wait until 3.0.0 is shipping with VSCode? |
For angular developers. till we get some fix, simple solution is to use work-space version instead of VsCodes one which is 2.7.2 in my case and everything works normally after that. |
@ratidzidziguri can you explain what you mean by using a "work-space" version? |
This last release of VS Code is so, so buggy. Hope an upgrade is coming soon! Does it make sense to allow people to revert after so many bugs were introduced? |
You can always set your workspace version of TS to an older (or newer!) version of TS. |
@lucasklaassen You can click on the right bottom toolbar of VS Code. Where you have the typescript version. From there you can choose the workspace version. |
Is there any chance this can get into a patch release? This apparently fixes #52089? Which is a pretty bad regression, it's loss of functionality. Basically auto imports import the wrong file. Thanks for all the hard work on this project. VS Code is awesome. |
Fixes microsoft/vscode#52089 and #25279