From 29028bbabefcedc1357ec2c05439567b643b42ca Mon Sep 17 00:00:00 2001 From: Braden Wong <13159333+braden-w@users.noreply.github.com> Date: Thu, 23 Oct 2025 15:59:35 -0700 Subject: [PATCH] docs(watch): rename filename to relativePath in recursive example (#23990) When using `fs.watch()` with `recursive: true`, the callback receives a relative path from the watched directory (e.g., `'subdir/file.txt'`), not just a filename. Renaming the parameter from `filename` to `relativePath` makes this behavior immediately clear to developers. **Before:** ```ts (event, filename) => { console.log(`Detected ${event} in ${filename}`); } ``` **After:** ```ts (event, relativePath) => { console.log(`Detected ${event} in ${relativePath}`); } ``` This is a documentation-only change that improves clarity without altering any functionality. Co-authored-by: Braden Wong --- docs/guides/read-file/watch.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/read-file/watch.md b/docs/guides/read-file/watch.md index b97c08d0e9..c1a792903f 100644 --- a/docs/guides/read-file/watch.md +++ b/docs/guides/read-file/watch.md @@ -24,8 +24,8 @@ import { watch } from "fs"; const watcher = watch( import.meta.dir, { recursive: true }, - (event, filename) => { - console.log(`Detected ${event} in ${filename}`); + (event, relativePath) => { + console.log(`Detected ${event} in ${relativePath}`); }, ); ```