Repository navigation
Fix indexing error in guessDirectorySymlink - #46105
Merged
Andrew Branch (andrewbranch) merged 2 commits intoSep 27, 2021
Merged
Conversation
Andrew Branch (andrewbranch)
requested review from
Daniel Rosenwasser (DanielRosenwasser) and
Andrew Casey (amcasey)
September 27, 2021 22:52
Daniel Rosenwasser (DanielRosenwasser)
approved these changes
Sep 27, 2021
Daniel Rosenwasser (DanielRosenwasser)
left a comment
Member
There was a problem hiding this comment.
I'd rather have a test, but looks like it hits a lot of projects and the code seems correct.
| const bParts = getPathComponents(getNormalizedAbsolutePath(b, cwd)); | ||
| let isDirectory = false; | ||
| while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && | ||
| while (aParts.length && bParts.length && |
There was a problem hiding this comment.
You could also check if they both have a length >= 2, right?
Member
Author
There was a problem hiding this comment.
Yeah, I forgot that / will be the first component all by itself, and / is never going to be a symlink itself, so that’s fine
Comment on lines
+6399
to
+6400
| function isNodeModulesOrScopedPackageDirectory(s: string | undefined, getCanonicalFileName: GetCanonicalFileName): boolean { | ||
| return s !== undefined && (getCanonicalFileName(s) === "node_modules" || startsWith(s, "@")); |
There was a problem hiding this comment.
Technically you don't need this with the >= 2 thing, but it's a fine guard.
Daniel Rosenwasser (DanielRosenwasser)
approved these changes
Sep 27, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #44953
I tried for about an hour to reverse engineer a failing test, but I wasn’t getting particularly close. I think some prerequisites of the failure are using project references,
useSourceOfProjectReferenceRedirect(which I think requires watch/tsserver, not tsc?), and having some symlinks.At any rate, I think the logical flaw this fixes is pretty obvious on its own and shouldn’t be held up by the fact that it’s only observable under pretty complicated conditions. This is something that would have been written correctly from the beginning, without tests, if written under
--noUncheckedIndexedAccess.