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 toml_doc::print_toml_document;
Modules§
- client
- I4 (#1970): the typed TypeScript client for a context’s foreign callers,
workers/<context>/bynk-client.ts(design/archive/retired-tracks.md, interop track D3). - contracts
bynk-contracts.jsongeneration per Worker (v0.177, #643).- secrets
bynk-secrets.jsongeneration per Worker (v0.172, ADR 0195).- toml_
doc - P7.3 (#1303): a minimal typed TOML tree and printer — the one piece of
R7.8 (
Artefactsis a keyed set of typed documents, never aStringat construction) landable ahead ofbynk-ts(Arc B, P7.5+), sincewrangler.tomlis the one documentbynk-emitproduces that isn’t TypeScript. Not a general TOML library:TomlValuerepresents exactly whatemitter::wrangler::emit_wrangler_tomlneeds to build awrangler.tomltoday, no more. - wrangler
wrangler.tomlgeneration per Worker (v0.8 §4.4 / §4.5).
Structs§
- System
Http Claims - #2019: what a
system-tier call needs to sign the claims a refinement actor’s predicate checks (actor Admin = User where hasClaim("admin")). A route guarded by a refinement has drivers that take a trailing claims object, signed into the JWT next tosub; a call acting as a refinement actor passes that actor’s witness claims, and any other call passes{}, so the Worker’s seam answers403exactly as it would a real token lacking the claim. - System
JobServices - #2136: the cron and queue services a
system-tier case drives through the participant Worker’s realscheduledandqueueentry points. Asvc.schedule("<expr>", …)address on a cron service here lowers to__sysdrive_schedule_<svc>_<index>(…), andq.message(m)on a queue service to__sysdrive_message_<q>(m)(tests_emit::emit_system_job_support).
Functions§
- 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. - emit_
tsconfig_ with_ source_ maps - The
bynkc test --coveragevariant (#854): the same config withsourceMapenabled, sotscemits the.js.maps the coverage remap consumes (hop 1,.js→ emitted.ts). Kept coverage-only rather than folded into the default so a normalbynkc test/ deploymenttscrun ships no.js.maps. The runner overwrites the defaultout/tsconfig.jsonwith this beforetsc.