Files
scriptc/tests/corpus/3060-dynamic-host-global.ts
Chris Tateandryoppippi 27f274c66e fix: expose host globals through dynamic globalThis (#476)
- Route explicit TypeScript globalThis escapes through the dynamic island.
- Initialize Node globals on first escaped access and cover C and LLVM parity.
- Document the island capabilities that remain conditional.

Fixes #34

Co-authored-by: ryoppippi <1560508+ryoppippi@users.noreply.github.com>
2026-09-26 17:37:45 -05:00

18 lines
709 B
TypeScript

// @dynamic
// An explicitly any-typed globalThis binding reaches the island's actual
// globals, including Node shims even when this program embeds no npm module.
const host: any = globalThis;
console.log(typeof host.process, host === (globalThis as any), host.global === host);
console.log(typeof host.Buffer, host.process === (globalThis as any).process);
const decoder: any = new (globalThis as any).TextDecoder("utf-8");
console.log(`${decoder.decode(new Uint8Array([72, 105]))}`);
host.process.stdout.write("host write\n");
console.log(host.__scriptc_absent__ === undefined);
function localGlobal(): string {
const local: any = globalThis;
return typeof local.Array;
}
console.log(localGlobal());