Expand description
TypeScript emission (spec §7, v0.1 §6, v0.2 §6).
Walks the typed AST and writes a single TypeScript module.
v0.2 lowering rules:
- Refined-base types: branded type alias + constructor object with
of/unsafe(+ any user-declared methods). - Record types: TypeScript
interface+ namespace object with methods. - Sum types: discriminated-union type alias + namespace object with variant constructors and methods.
- Field access lowers to property access.
- Method calls lower to
Type.method(receiver, args)(UFCS). matchlowers to a switch on.tag; in tail position it inlines, otherwise it becomes an IIFE.islowers to a tag check; bindings becomeconstdeclarations on the truthy side ofif/&&.
Re-exports§
pub use workers::emit_worker_compose;pub use workers_entry::emit_worker_entry;pub use wrangler::emit_wrangler_toml;
Modules§
- serialisation
- Per-type serialise / deserialise helper generation for workers mode (v0.8 §3.4 / §5.2).
- workers
- Per-Worker composition root generation (v0.8 §4.5, v0.9 §5.1).
- workers_
entry - Per-Worker
index.tsgeneration (v0.8 §4.3, v0.9 §5.1). - wrangler
wrangler.tomlgeneration per Worker (v0.8 §4.4 / §4.5).
Functions§
- agent_
factory_ name - The exported agent-construction factory name for an agent class.
- emit
- Emit TypeScript source for the typed commons (single-file mode).
- emit_
project - Emit TypeScript source for a single file inside a multi-file project,
including cross-file and cross-commons imports computed from
EmitProjectCtx. Emit one unit’s TypeScript, plus its source map (slice 1, ADR 0103). - emit_
runtime_ module - Emit the contents of
out/runtime.ts. This module ships with every project so the per-context / per-test emissions canimport { Ok, Err, Some, None, ... }from a single source. It includes: - emit_
tsconfig - Emit the contents of
out/tsconfig.json. The CLI usestsc -pagainst this when runningbynkc test; users can also drivetscagainst it directly to produce JS for deployment. - runtime_
import_ for - Compute the runtime import specifier for a module at
from_source. For a file atcommerce/payment.tsthe runtime sits two levels up, so this returns../runtime.js; for a top-level file it returns./runtime.js.