/** * emit-typescript-native.ts — TS NATIVE codegen emitter (`typescript-native`, bc#135). * * A first-class, consumable, interpreter-free TypeScript codegen target — parallel to * `go-typed-native` / `rust-typed-native`. It coexists with `typescript` (literal, ir-exec) and * `typescript-typed` (the #46 oracle); it does NOT replace or change them. * * ── What this delivers (honest scope — bc#31/#32 CLOSED) ──────────────────────────────────── * bc#31 concluded AOT-literal ≈ ir on PERFORMANCE for TS: TS type-erasure means there is NO * runtime de-boxing win (all field access is dynamic at runtime regardless), unlike go/rust which * materialize concrete structs (#47/#48). So this is **NOT a performance feature**. Its value is: * 1. An HONEST codegen surface — the generated module genuinely emits TS execution LOGIC * (straight-line statements, direct handler-thunk calls), NOT "embed the IR blob and interpret * it via runBehavior". The portable IR is not embedded; there is no per-node nodeKind dispatch * and no Expression-IR tree-walk in the executable path. * 2. COMPILE-TIME TYPE SAFETY — `tsc --strict` proves that node results, cross-node field access, * and the assembled component output all conform to the declared portable types * (`outType`/`outputType`). A typed entry surface (`bindTyped`) returns values typed as the * component `outputType`, materialized through real marshaller functions. * 3. DE-INTERPRETATION — reuses the language-agnostic straight-line lowering (straightline.ts, * buildTypePlan, assertStraightlineSupported) already shared by go/rust, and the existing * straight-line TS runtime (emit-shared-typescript.ts) for the executable body. * * ── What necessarily REMAINS (no overclaim) ───────────────────────────────────────────────── * - Operator-semantics primitive calls (`cgp.add`/`cgp.concat`/… — the A0 SSoT): named & explicit, * NOT re-interpreted. Their semantics stay single-sourced. * - The handler `Value` boundary: handlers are injected generically and return boxed `Value`; the * typed marshaller asserts/casts the boxed result at that boundary. Under TS erasure that `as T` * is a runtime no-op — which is EXPECTED and fine. It is the point where `tsc` checks the shape. * * ── Relationship to the TS TypedMaterializer seam (typed.ts) ──────────────────────────────── * The seam (go/rust #47/#48) exposes runtime-materialization hooks: `emitMarshallers`, * `materializeExpr`, `typedFieldAccess`, `serializeTyped`. The `typescript-typed` oracle implements * ONLY the decls-only subset (`emitTypeDecls`/`renderTypeRef`) — its typed layer is a dead-on-runtime * verification oracle. This emitter moves the TS side ONTO the runtime-materialization hooks * (`tsNativeTypedMaterializer`, in emit-shared-typescript-typed.ts): the typed layer here is * REACHABLE — `bindTyped()` runs the straight-line body and materializes each covered component's * result through `marshalOutput_` (a real function that walks the outputType shape), so the * `as T` boundary + typed field access are on a live typed path, not a dead oracle. Under erasure the * runtime is byte-identical to the straight-line body (the equivalence pin), while `tsc` proves the * typed surface. * * ── Backward compatibility ────────────────────────────────────────────────────────────────── * IR with NO `outType`/`outputType` anywhere → the typed layer is not emitted and the output is * byte-identical to the straight-line runtime (the same body `typescript-typed` emits for untyped * IR). The untyped byte-identical pin therefore holds against `typescript-typed`. */ import type { EmitterPlugin } from "./core.js"; /** * typescriptNativeEmitter — language id `typescript-native` (bc#135). A first-class executable TS * native codegen target: interpreter-free straight-line runtime + a REACHABLE typed materialization * layer (`bindTyped`) that `tsc --strict` verifies. Coexists with `typescript` (literal) and * `typescript-typed` (oracle). Untyped IR → byte-identical to the straight-line runtime. */ export declare const typescriptNativeEmitter: EmitterPlugin; //# sourceMappingURL=emit-typescript-native.d.ts.map