Skip to content

Conversation

@joshcartme
Copy link
Contributor

@joshcartme joshcartme commented May 30, 2025

quick explanation:
Absolute paths like "/some/path/glob/**" were getting through when the correct path would be `"/some/path/glob"``

long:
An include like ../../ambient-types/**/* is turned into an absolute path, let's say /home/dev/project/ambient-types/**/* and passed here

func getIncludeBasePath(absolute string) string {
wildcardOffset := strings.IndexAny(absolute, string(wildcardCharCodes))
if wildcardOffset < 0 {
// No "*" or "?" in the path
if !tspath.HasExtension(absolute) {
return absolute
} else {
return tspath.RemoveTrailingDirectorySeparator(tspath.GetDirectoryPath(absolute))
}
}
return absolute[:strings.LastIndex(absolute, string(tspath.DirectorySeparator))]
}

That strips the last chunk of the path, so returns /home/dev/project/ambient-types/**. Then patterns in
patterns := getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory)
ends up with one of it's base paths as /home/dev/project/ambient-types/** and that is not a valid path to visit in
func (v *visitor) visitDirectory(
path string,
absolutePath string,
depth *int,
) {
canonicalPath := tspath.GetCanonicalFileName(absolutePath, v.useCaseSensitiveFileNames)
if v.visited.Has(canonicalPath) {
return
}
v.visited.Add(canonicalPath)
systemEntries := v.host.GetAccessibleEntries(absolutePath)
files := systemEntries.Files
directories := systemEntries.Directories
so systemEntries.Files and systemEntries.Directories are empty and any files represented by that include are not found.

Things do work with implicit globs, so if that include was ../../ambient-types the basePath ends up as /home/dev/project/ambient-types and the files and/or directories are found.

This is attempting to address #980

Absolute paths like "/some/path/glob/**" were getting through when the correct path would be "/some/path/glob"
@jakebailey jakebailey enabled auto-merge May 30, 2025 23:44
@jakebailey jakebailey added this pull request to the merge queue May 31, 2025
Merged via the queue into microsoft:main with commit b53f521 May 31, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants