Remove FS().WalkDir - #64277
Remove FS().WalkDir#64277
Conversation
There was a problem hiding this comment.
🟡 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
WalkDirimplementations, mocks, and legacy tests. - Adds
vfs.WalkDirwith 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.WalkDirtreatsSkipDirreturned for a root file (or root symlink) as a successful stop, but this only consumesSkipAll;WalkDirtherefore unexpectedly returnsfs.SkipDirto the caller. Consume both sentinels at the top level, matching the nested-file handling andfs.WalkDirsemantics.
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.
There was a problem hiding this comment.
🟢 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
Jake Bailey (jakebailey)
left a comment
There was a problem hiding this comment.
I think this makes sense.
|
I'll wait for #64269 to merge. |
|
Never mind, #64285 could use the helper. |
This is something I wanted to do way back when I was implementing the LSP infrastructure because I noticed that
WalkDirhad no production callers, and wasn't possible to cache incachedvfs, 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.WalkDirhelper function that implements WalkDir-like behavior in terms ofGetAccessibleEntries,Realpath, andStat. 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).