mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
readFileSync, writeFileSync, appendFileSync, statSync, lstatSync, readdirSync, mkdirSync, rmSync, rmdirSync, mkdtempSync, accessSync, unlinkSync, chmodSync, chownSync, lchownSync, truncateSync, copyFileSync, renameSync, realpathSync, realpathSync.native, openSync and opendirSync accept a file: URL wherever they accept a path. The URL converts as fileURLToPath converts it, with Node's errors for other schemes, hosts, encoded separators and null bytes. Arguments after a URL path that have side effects are evaluated into hidden locals before the conversion, so they run even when it throws. A URL path after a string path, or with options that are not literals, fails with SC2020, because Node checks those arguments before it converts the URL. existsSync and the fs.promises functions also fail with SC2020 for URL paths: existsSync answers false for a URL it cannot convert, and fs.promises reports conversion errors as rejections. Fixes #1616 Co-authored-by: jlucaso1 <55464917+jlucaso1@users.noreply.github.com>
node-types fixture
A project whose node_modules contains @types/node — the adoption path for real-world Node/TypeScript projects. The vendored node_modules are COMMITTED TEST DATA, pinned so the type surface (and therefore the pinned diagnostics) never drifts with the registry:
@types/node24.13.3undici-types7.18.2 (its dependency — declares the web-platform globals: fetch/Response/AbortSignal/ReadableStream/...)
What the fixture pins (see tests/harness/project-config.test.ts):
argv-env.ts— the SUPPORTED process surface (argv, env) typed by @types/node lowers statically and the binary runs: with @types/node present, the shipped fallback declarations forprocess/node:fs/consolestand down (their types come from @types/node), but the same members lower to the same libCalls, recognized by name + @types/node provenance.fenced.ts— surface @types/node DECLARES but scriptc does not lower (process.uptime, Buffer.from, setInterval) reports the SC2020-family fence naming @types/node, instead of typechecking its way into a broken binary — and never a raw "Cannot find name" error.event-loop-metrics.tsandtimeout-type.ts— performance.eventLoopUtilization, monitorEventLoopDelay's IntervalHistogram and NodeJS.Timeout as declared types lower under @types/node exactly as under the fallback declarations.source-import/— an imported TypeScript source may use theRequestInfoglobal supplied by TypeScript's default DOM lib while scriptc adopts the project's @types/node declarations.
Projects WITHOUT @types/node (every other fixture and the whole corpus) keep the shipped fallback declarations and behave exactly as before.