Skip to main content

emit_runtime_module

Function emit_runtime_module 

pub fn emit_runtime_module() -> String
Expand description

Emit the contents of out/runtime.ts. This module ships with every project so the per-context / per-test emissions can import { Ok, Err, Some, None, ... } from a single source. It includes:

  • Result/Option discriminated unions (using tag for the discriminant — same shape user sum types lower to).
  • ValidationError (the record shape refined-value constructors return).
  • The DurableObjectState/DurableObjectStorage interfaces that agent classes consume, plus an InMemoryStorage implementation and a makeTestState(name) factory for use in test execution.

The content is identical across projects — there is no per-project tailoring. Dead code is harmless; tsc handles it.