mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
net.SocketAddress and net.BlockList were refused at compile time. They are now native checked-dynamic handles in scr_net.c, so their getters and methods also work on untyped values, and they match Node 24: - new SocketAddress(options) checks the options in Node's order (ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE for the family, ERR_SOCKET_BAD_PORT, ERR_OUT_OF_RANGE for the flow label) and throws ERR_INVALID_ADDRESS for an address that does not parse. parse() reads URL.parse(`http://${input}`)'s hostname and port and answers undefined on failure; isSocketAddress(), toJSON() and util.inspect match. - BlockList takes address, range, subnet and CIDR rules (addAddress, addAddresses, addRange, addSubnet, addCIDR, addCIDRs), removes them (removeAddress, removeRange, removeSubnet, removeCIDR, clear) and lists them in Node's order: IPv4 addresses, IPv6 addresses, subnets, then ranges, each newest first, with a repeated address kept once. - check() compares across families through the IPv4-mapped IPv6 form, as Node's SocketAddress::compare and is_in_network do, and answers false for a string that does not parse in the given family. - rules, size, toJSON(), fromJSON() (Node's rule patterns), isBlockList(), PRIVATE_RANGES, instanceof and util.inspect match, with the validation errors of lib/internal/blocklist.js. Corpus 5659 and the node-types fixture net-blocklist.ts cover both classes. The compatibility registry lists the BlockList methods and SocketAddress.parse as supported, and both classes as partial: their structured clone and worker transfer forms are not modeled.
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.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.