mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
Node's writeFileSync accepts an open file descriptor where it accepts a path: it writes the data at the descriptor's current offset and leaves the descriptor open, since closeSync owns its lifetime. The static fs surface declared only the path forms, so `fs.writeFileSync(fd, text)` failed type mapping — the compiler was missing a documented overload, not a conversion. Declare the (fd, data) and (fd, data, "utf8" | "utf-8") forms in the node-fallback typings, route the call by the first argument's static f64 type to a new fs.writeFileSyncFd libfn, and implement it as scr_fs_write_file_fd: a write loop over the whole string through the descriptor-validating scr_fs_write_bytes, resuming short writes, with the descriptor operation's errno shape on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>