-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix package.json auto imports for pnpm without project references #43892
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
Conversation
src/compiler/moduleNameResolver.ts
Outdated
resolvedTypeReferenceDirective = { | ||
primary, | ||
resolvedFileName, | ||
originalFileName: fileName === resolvedFileName ? undefined : fileName, |
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 this should be originalPath
just like in ResolvedModuleFull
..
checkout createResolvedModuleWithFailedLookupLocations , you would want to do something similar
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 it needs to be the (original casing preserved) file name instead of a lowercased Path in order to use the correct casing during module specifier resolution. Though I see originalPath
is string
and not Path
too, so maybe I’m confused by the existing names 🤔
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.
It is string and not Path, check in nodeModuleNameResolverWorker
though it seems like it should compare paths there and not strings as there could be case difference.( but thats separate issue that @amcasey might want to look in for his realpath fix he was working on )
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 if it’s not going to be normalized into a Path
, the property name should use fileName
and not path
. And if we don’t preserve the file name, I think test cases like https://github.com/microsoft/TypeScript/blob/master/tests/cases/fourslash/autoImportSymlinkCaseSensitive.ts will start having issues.
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.
Sorry i wasnt very clear in my comment.. What i was saying was that comparison needs to be between Path
but value needs to be string.
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.
Ah, I see, just for the equality comparison. It doesn’t look like I have easy access to the current directory or getCanonicalFileName
(the latter is optional on ModuleResolutionHost
) and this is public API. What do you suggest doing?
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 dont think you need to fix it in this PR. But module resolution host has optional getCurrentDirectory
so we can add useCaseSensitiveFileNames?(): boolean
and use Path if both methods exist and compare filenames otherwise.
you would also want to make sure our all internal moduleResolutionHosts
have these implemented. Again dont think this is part of your PR but needs to be handled at some point for @amcasey realpath native methods to be used
@andrewbranch you are doing change to use |
@sheetalkamat from the thread:
Since we agreed the type should be |
But you still need to copy |
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.
typeDirectiveIsEqualTo needs to be updated to take into account this new field
@sheetalkamat I looked into this and |
sorry about that , i missed the fact that realpath is called just above this and not coming from the resolved value. So your current change is right. |
…to `discoverProbableSymlinks`
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.
Not ideal that we have originalPath
in resolvedModule and originalFileName
in resolvedTypeReferenceDirective from consistency point of view but not stuck on that.
I can change it to |
Also just noticed that |
Fixes #42094—read about the reason for the symptom and the rationale behind the fix there. I’m not 100% confident this is the most direct way to fix the problem; open to other ideas if they’re not super complicated.