Files
scriptc/tests/corpus/file-handle-values.ts
Chris Tate 0053372853 Compile native renderer startup callables and dictionaries
- Support stored builtin helpers, typed rest callbacks, and shared FileHandle values.
- Preserve async results, specialized function bodies, and checked class receivers.
- Compile live export dictionaries and keep native property names distinct.
2026-09-28 14:53:57 -05:00

17 lines
566 B
TypeScript

import { open, unlink } from "node:fs/promises";
import type { FileHandle } from "node:fs/promises";
const path = `/tmp/scriptc-file-handle-values-${process.pid}.txt`;
const handle = await open(path, "w+", 0o600);
try {
const stored: unknown = handle;
const alias: FileHandle = stored as FileHandle;
console.log(handle === alias, alias.fd === handle.fd);
await alias.writeFile("native", "utf8");
console.log((await handle.stat()).size);
await alias.close();
console.log(handle.fd, alias.fd);
await handle.close();
} finally {
await unlink(path);
}