scriptgo targets a standard library surface compatible with modern JavaScript
runtimes (ECMAScript standards, Node.js 22 LTS, and WinterCG server APIs) so
useful backend, CLI, and systems TypeScript code can compile to efficient
native binaries.
TypeScript-Go remains responsible for parsing, binding, module resolution, and
type checking; scriptgo owns native eligibility, runtime mapping, and parity
verification.
To maintain clear module boundaries and enable robust Gate Parity Checking, all built-ins and runtime symbols are categorized into four distinct groups:
┌──────────────────────────────────────────────────────────────┐
│ TypeScript / JavaScript Source │
└──────────────────────────────┬───────────────────────────────┘
│
┌────────────────┴────────────────┐
│ │
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐
│ Language Environment │ │ Node Environment │
└────────────┬─────────────┘ └────────────┬─────────────┘
│ │
▼ ┌─────────────┼─────────────┐
┌──────────────────────────┐ ▼ ▼ ▼
│ 1. ECMAScript Built-ins │ ┌──────────┐ ┌──────────┐ ┌─────────────┐
│ │ │ 2. Web │ │ 3. Node │ │ 4. Built-in │
│ Array, Object, Math │ │ globals │ │ globals │ │ modules │
│ JSON, Promise, Map │ │ │ │ │ │ │
│ Set, RegExp, Date, ... │ │ fetch │ │ process │ │ node:fs │
└──────────────────────────┘ │ URL │ │ Buffer │ │ node:path │
│ Request │ │ console* │ │ node:os │
│ Response │ │ setImm...│ │ node:crypto │
│ Abort... │ │ ... │ │ node:http │
└──────────┘ └──────────┘ └─────────────┘
| Category | Examples | Scope & Meaning | Import Required? | Parity Test Oracle (Gate) |
|---|---|---|---|---|
| 1. ECMAScript built-ins | Array, Object, Promise, Math, JSON, Map, Set, Error, Number, String, NaN, Infinity |
Defined strictly by ECMA-262 specifications. Not tied to Node.js or browser hosts. | NO (Global Scope) | ECMA Test262 test suite & TypeScript baselines |
| 2. Web-compatible globals | fetch, Headers, Request, Response, URL, URLSearchParams, AbortController, AbortSignal, TextEncoder, TextDecoder, Blob, structuredClone, setTimeout, queueMicrotask, performance |
Standard Web APIs adopted globally across server runtimes (WinterCG / Node.js). Excludes browser DOM APIs. | NO (Global Scope) | WPT (Web Platform Tests) & Node.js Web API suite |
| 3. Node-specific globals | process, Buffer, setImmediate, clearImmediate, __dirname, __filename, global, console |
Host environment APIs injected by Node.js runtime bootstrap. | NO (Global Scope) | Node.js 22 LTS globals test suite |
| 4. Node built-in modules | node:fs, node:path, node:crypto, node:os, node:events, node:util, node:process, node:child_process |
Standard library modules explicitly imported via node:* or bare specifiers. |
YES (import / require) |
Node.js 22 LTS test/parallel/test-*.js suites |
Any symbol in Categories 1, 2, or 3 is available in every file automatically without an import statement:
- ECMAScript:
Math.max(1, 2),JSON.parse(str),const arr = new Array() - Web Globals:
const url = new URL(input),await fetch(url),setTimeout(fn, 100) - Node Globals:
console.log("log"),process.cwd(),Buffer.from("abc")
Symbols in Category 4 are encapsulated within standard modules and cannot be called from the global scope. They require an explicit import statement:
// Canonical Node.js import (Recommended)
import * as fs from "node:fs";
import * as crypto from "node:crypto";
import { join, dirname } from "node:path";
// Bare specifier compatibility alias
import * as path from "path";Certain concepts exist in both the global scope and as a dedicated module. scriptgo enforces the following semantic boundary:
| Symbol / API | Global Usage (No Import) | Module Usage (import ... from 'node:*') |
|---|---|---|
process |
Category 3 Global: process.argv, process.cwd(), process.exit() |
Category 4 Module: import process from "node:process" (ESM specifier alias to global instance) |
crypto |
Not available globally | Category 4 Module: import * as crypto from "node:crypto" (crypto.randomUUID(), etc.) |
Buffer / buffer |
Category 3 Global: Buffer.from(), Buffer.alloc() |
Category 4 Module: import { Buffer } from "node:buffer" (Module-level exports, Blob/constants) |
Timers / timers |
Category 2 Web Global: setTimeout, setInterval, clearTimeout |
Category 4 Module: import { setTimeout } from "node:timers/promises" (Promise-based timer variants) |
scriptgo is a native backend/systems compiler targeting servers, CLIs, and
high-performance tools. It is not a browser engine and does not support
DOM layout or UI rendering.
- HTTP & Networking:
fetch,Headers,Request,Response,FormData - URL & Routing:
URL,URLSearchParams,URLPattern - I/O Streams:
ReadableStream,WritableStream,TransformStream,ByteLengthQueuingStrategy - Cancellation & Signals:
AbortController,AbortSignal - Binary & Text Encoding:
TextEncoder,TextDecoder,Blob,File - Base64 & Utilities:
btoa,atob,structuredClone - Events Core:
Event,EventTarget,CustomEvent - Timers & Microtasks:
setTimeout,clearTimeout,setInterval,clearInterval,queueMicrotask - High-Resolution Time:
performance(performance.now(),PerformanceMark) - Real-time Comms (Future):
WebSocketclient
These APIs will not be admitted to the native runtime:
- DOM Tree & HTML Elements:
window,document,HTMLElement,Element,Node,HTMLDivElement,ShadowRoot,DocumentFragment. - Browser Client Storage & History:
localStorage,sessionStorage,indexedDB,history,location. - Graphics & CSS Rendering:
requestAnimationFrame,Canvas,WebGL,CSSStyleDeclaration,IntersectionObserver,MutationObserver,ResizeObserver. - Browser Hardware / UI Events:
MouseEvent,KeyboardEvent,TouchEvent,AudioContext,Geolocation,Notification,ServiceWorker,WebRTC(RTCPeerConnection).
The standard library participates in the same three-tier compilation policy as
application code (see compilation-tiers.md):
- Static: Pure TypeScript stdlib or a versioned native primitive whose behavior is proven and compiled directly into the native executable.
- Dynamic: JavaScript/npm library code that requires full JavaScript dynamic
semantics or reflection, executed through embedded QuickJS-ng when
--dynamicis enabled. - Unsupported: An API with no implemented Static or Dynamic contract; compilation fails with a source-anchored diagnostic.
Every standard-library surface admitted to the compiler must satisfy the following parity verification criteria:
- Documented Reference: Pin parity claims to ECMAScript 2022+ and Node.js 22 LTS.
- Oracle Verification:
- ECMA Built-ins: Must pass matching Test262 test cases.
- Web Globals: Must pass relevant WPT tests without browser-specific DOM assumptions.
- Node Globals & Modules: Must match Node.js 22 LTS observable stdout, exit codes, exceptions, and error messages.
- Multi-Target Coverage:
- Reference interpreter test fixture (
internal/interpreter). - Native LLVM compiled executable test fixture (
internal/compiler/testdata/corpus/stdlib/).
- Reference interpreter test fixture (
- Differential Parity Gate: CI checks run differential assertions verifying
identical outputs between
node <test>.tsandscriptgo run <test>.ts.
Both bare specifiers and canonical node: prefixed specifiers are supported:
import * as path from "node:path"; // Canonical Node.js style
import * as fs from "fs"; // Bare compatibility aliasLowering and the module loader canonicalize module specifiers while preserving accurate source spans in compiler diagnostics.
Implement standard-library functionality following this hierarchy:
Native C ABI Primitives -> Core TypeScript stdlib -> High-level TypeScript stdlib
- TypeScript First: Implement stdlib features in pure TypeScript whenever the logic can be expressed with existing language primitives.
- Minimal C Runtime: Use C only for OS syscalls, memory allocation, POSIX bindings, or platform-specific adapters.