Files
scriptc/tests/diagnostics/node-fallback-fence.ts
Chris Tate 3f56576644 feat(compiler): rebuild the frontend with native compiler stages (#568)
- Share frontend loading, package selection, contracts, and FFI parsing between Node and native clients.
- Preserve collection layouts and optional method returns while lowering long nullish chains without recursive stack growth.
- Rebuild the frontend from TypeScript through native lowering and C emission with matching output.
2026-09-29 07:45:18 -05:00

38 lines
2.1 KiB
TypeScript

// The widened fallback ambient world: the Node/web surface real CLI
// sources reference TYPECHECKS under the fallback declarations (no
// @types/node needed to preflight) and every reached use without a
// lowering terminates in a clean SC2020-family diagnostic at its use
// site — the coverage report's honest blocker list, never a raw
// "Cannot find name". fetch, RequestInit, and AbortSignal lower natively.
// setInterval/clearInterval, process.on/once/off (signals and "exit"),
// the stdin events, and stdin.destroy() all LOWER now — the fences here
// are the members BEYOND the lowered slice.
const timer = setInterval(() => {}, 50);
clearInterval(timer);
process.stdin.destroy();
process.on("SIGINT", () => {});
process.once("exit", () => {});
process.off("exit", () => {});
process.stdin.setEncoding("utf8"); // terminal streams accept a text encoding
const buf = Buffer.from("x", "utf8").reverse(); // from and fill lower; reverse fences
const enc = new TextEncoder().encode("x");
const dec = new TextDecoder().decode(enc);
const signal = AbortSignal.timeout(1000);
const res = fetch("https://example.com", { signal });
const tty = process.stdout.isTTY;
const errTty = process.stderr.isTTY;
import { accessSync, constants, mkdtempSync, readFileSync } from "node:fs";
import { setInterval as promiseInterval } from "node:timers/promises";
accessSync("/bin/sh", constants.X_OK);
const tmp = mkdtempSync("/tmp/scr-");
const raw = readFileSync("/etc/hosts").toString(tty ? "hex" : "latin1"); // runtime BufferEncoding selection lowers too
const intervalWithSignal = promiseInterval(1, "tick", {}); // AbortSignal options stay fenced
// The computed encoding is now part of the static Buffer surface. The
// one-shot zlib/raw/gzip codecs also accept literal compression levels;
// other options stay fenced, while Brotli remains an explicit member fence.
import { brotliCompressSync, deflateSync } from "node:zlib";
const packed = deflateSync("data", { level: 9, strategy: 1 }); // strategy remains fenced
const brotli = brotliCompressSync(Buffer.from("data")); // outside the lowered family: fenced
// The remaining imports continue the declared-but-not-lowered surface.