Skip to content

node:fs: accept the readdir recursive/withFileTypes values node accepts - #39330

Open
robobun wants to merge 3 commits into
mainfrom
farm/56a47b54/readdir-option-acceptance
Open

node:fs: accept the readdir recursive/withFileTypes values node accepts#39330
robobun wants to merge 3 commits into
mainfrom
farm/56a47b54/readdir-option-acceptance

node:fs: accept the readdir recursive/withFileTypes values node accepts

1092978
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 16, 2026 in 14m 46s

Code review found 1 potential issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/js/node/fs.promises.ts:311-315 promises.readdir spread drops inherited encoding/withFileTypes when coercing recursive

Annotations

Check warning on line 315 in src/js/node/fs.promises.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

promises.readdir spread drops inherited encoding/withFileTypes when coercing recursive

nit: `{ ...options }` copies own-enumerable properties only, so an inherited `withFileTypes`/`encoding` (e.g. `const opts = Object.create({ withFileTypes: true }); opts.recursive = 1`) is dropped before the native parser sees it — Node returns `Dirent[]` here, this returns `string[]`. `options = { __proto__: options, recursive: !!recursive }` preserves the prototype chain without mutating the caller's object (the native parser already walks the prototype via `val.get`).