Skip to content

Remove FS().WalkDir - #64277

Merged
Andrew Branch (andrewbranch) merged 3 commits into
microsoft:mainfrom
andrewbranch:remove-walkdir
Sep 15, 2026
Merged

Andrew Branch (andrewbranch) merged 3 commits into
microsoft:mainfrom
andrewbranch:remove-walkdir

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

This is something I wanted to do way back when I was implementing the LSP infrastructure because I noticed that WalkDir had no production callers, and wasn't possible to cache in cachedvfs, which would make it prone to violating snapshot guarantees if it was implemented. Similar friction came up again in #64269, where it's just difficult to implement WalkDir correctly in a highly composed filesystem, and then I remembered that we don't have to.

Unfortunately, I later added one production caller (🤦🏻‍♂️), but it’s easy to remove. In the second commit, I tried making a top-level vfs.WalkDir helper function that implements WalkDir-like behavior in terms of GetAccessibleEntries, Realpath, and Stat. It does make the previous callers (one production and a few test) simpler, but I'm not sure if it's worth it. Without the second commit, this PR is almost all deletion (-638 +96).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new helper mishandles top-level skip sentinels and can report the wrong name for a symlink root.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Removes WalkDir from the VFS interface and replaces required traversal with a composable helper based on cached VFS primitives.

Changes:

  • Removes WalkDir implementations, mocks, and legacy tests.
  • Adds vfs.WalkDir with symlink-aware traversal tests.
  • Migrates LSP, fourslash, and configuration callers.
File summaries
File Description
tsc/internal/vfs/wrapvfs/wrapvfs.go Removes WalkDir wrapping.
tsc/internal/vfs/walkdir.go Adds traversal helper.
tsc/internal/vfs/walkdir_test.go Tests traversal behavior.
tsc/internal/vfs/vfstest/vfstest_test.go Updates stress operations.
tsc/internal/vfs/vfsmock/wrapper.go Removes mock delegation.
tsc/internal/vfs/vfsmock/mock_generated.go Removes generated mock API.
tsc/internal/vfs/vfs.go Shrinks the FS interface.
tsc/internal/vfs/trackingvfs/trackingvfs.go Removes tracking wrapper.
tsc/internal/vfs/osvfs/os.go Removes OS traversal implementation.
tsc/internal/vfs/iovfs/iofs.go Removes IOFS traversal.
tsc/internal/vfs/iovfs/iofs_test.go Removes obsolete tests.
tsc/internal/vfs/internal/internal.go Removes common traversal.
tsc/internal/vfs/cachedvfs/cachedvfs.go Removes uncached delegation.
tsc/internal/vfs/cachedvfs/cachedvfs_test.go Removes delegation tests.
tsc/internal/tsoptions/tsconfigparsing_test.go Migrates filesystem printing.
tsc/internal/project/snapshotfs.go Removes sourceFS traversal.
tsc/internal/lsp/lspwatcher/lspwatcher.go Migrates synthetic-create traversal.
tsc/internal/fourslash/fourslash.go Uses accessible-file collection.
tsc/internal/fourslash/baselineutil.go Adds shared file collection.
tsc/internal/compiler/projectreferencedtsfakinghost.go Removes unsupported method.
tsc/internal/bundled/generate.go Stops generating directory entries.
tsc/internal/bundled/embed.go Removes embedded traversal.
tsc/internal/bundled/embed_generated.go Updates generated output.
tsc/internal/bundled/bundled_test.go Tests direct directory listing.
tsc/internal/api/requestfilesystem/requestfilesystem.go Removes bespoke traversal.
tsc/internal/api/requestfilesystem/requestfilesystem_test.go Updates request-FS tests.
tsc/internal/api/requestfilesystem/pathtree_test.go Replaces traversal assertions.
tsc/internal/api/callbackfs.go Removes base delegation.
Review details

Files not reviewed (3)

  • tsc/internal/bundled/embed_generated.go: Generated file
  • tsc/internal/bundled/generate.go: Generated file
  • tsc/internal/vfs/vfsmock/mock_generated.go: Generated file

Suppressed comments (1)

tsc/internal/vfs/walkdir.go:140

  • fs.WalkDir treats SkipDir returned for a root file (or root symlink) as a successful stop, but this only consumes SkipAll; WalkDir therefore unexpectedly returns fs.SkipDir to the caller. Consume both sentinels at the top level, matching the nested-file handling and fs.WalkDir semantics.
	if err := visit(root, rootEntry, rootRealpath); errors.Is(err, fs.SkipAll) {
  • Files reviewed: 25/28 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread tsc/internal/vfs/walkdir.go
Comment thread tsc/internal/vfs/walkdir.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The interface removal is consistently applied, callers are migrated, and the replacement traversal behavior has focused coverage.

Review details

Files not reviewed (3)

  • tsc/internal/bundled/embed_generated.go: Generated file
  • tsc/internal/bundled/generate.go: Generated file
  • tsc/internal/vfs/vfsmock/mock_generated.go: Generated file
  • Files reviewed: 25/28 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@jakebailey Jake Bailey (jakebailey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this makes sense.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 15, 2026
@andrewbranch

Copy link
Copy Markdown
Member Author

I'll wait for #64269 to merge.

@andrewbranch

Copy link
Copy Markdown
Member Author

Never mind, #64285 could use the helper.

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Sep 15, 2026
Merged via the queue into microsoft:main with commit d2b20b3 Sep 15, 2026
26 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the remove-walkdir branch September 15, 2026 21:03
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants