Skip to content

ADR-011: Emmett/TypeScript as First Code Generation Target

Context

Weltenwanderer needs at least one code generation target to be useful. Candidates evaluated:

OptionStack matchEvent storeBoilerplateEcosystem
Emmett/TypeScriptYes (Bun/TS)Built-inLowLarge
Axon 5 (Java)NoBuilt-inMediumLarge
PostgreSQL native SQLPartialManualHighN/A
Custom runtimeN/AManualVery highNone

The choice of first target shapes generator abstractions that all future targets must fit within.

Decision

Emmett/TypeScript is the first and initially only code generation target. Per-decider output consists of: a decider class, smart constructors (from validate constraints), event/state union types, and Emmett wiring. The generator architecture is designed to accommodate future targets (Axon 5, PostgreSQL, WASM) via separate generator packages, but only Emmett is implemented in Phase 4.

Level 2 verification uses fast-check (TypeScript property-based testing) against the generated code, consistent with the TypeScript-first choice.

Consequences

Positive

  • TypeScript matches the compiler’s own stack — no language boundary in the toolchain.
  • Emmett provides event store, projection setup, and decider wiring, reducing generated boilerplate.
  • fast-check enables property-based Level 2 verification without a second language runtime.
  • Large TypeScript ecosystem for consumers of generated code.

Negative

  • First target biases generator abstractions toward TypeScript patterns; future targets may need adapters.
  • Emmett-specific wiring code (e.g., CommandHandler, EventStore types) may not generalize.
  • Java/SQL targets require separate generator packages with their own test suites.