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/&&.
Modules§
- contracts
bynk-contracts.jsongeneration per Worker (v0.177, #643).- secrets
bynk-secrets.jsongeneration per Worker (v0.172, ADR 0195).- wrangler
wrangler.tomlgeneration per Worker (v0.8 §4.4 / §4.5).
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.