Typra
Typra turns TypeSpec model contracts into runtime model surfaces, generated tests, generated documentation, and reviewable metadata.
Use it when TypeSpec is the source of truth for shared data shapes and multiple runtimes need to agree on loading, saving, provider wire names, polymorphism, and generated API shape.
Typra is deliberately emitter-only. It generates model and protocol surfaces, but product-specific TypeSpec contracts, service behavior, and hand-authored adapters stay in the consuming product.
Documentation map
Section titled “Documentation map”| Section | Use it for |
|---|---|
| Concepts | The mental model, a simple example, and the end-to-end generation flow. |
| TypeSpec Mappings | How TypeSpec shapes lower into Typra concepts and generated runtime surfaces. |
| Targets | What each output target looks like and which options matter for that runtime. |
| Reference | Configuration, CLI commands, compatibility, verifier behavior, and roadmap details. |
When to use Typra
Section titled “When to use Typra”| Use Typra when… | Keep hand-authored code when… |
|---|---|
| TypeSpec is the durable source of truth for shared model shapes. | Behavior depends on product-specific runtime decisions. |
| Multiple runtimes need consistent serialization and wire names. | A one-off integration does not need generated parity. |
| Generated output will be reviewed in CI. | The shape is still exploratory and changing daily. |
| Tests and metadata help teams trust code generation. | Custom adapters or service implementations are the actual product logic. |
Current compatibility
Section titled “Current compatibility”@typra/emitter currently validates against @typespec/compiler and @typespec/json-schema 1.10.0. Unsupported TypeSpec versions report an emitter diagnostic unless allow-unsupported-typespec-version: true is set intentionally.
What Typra gives you
Section titled “What Typra gives you”- Runtime model code for TypeScript, Python, C#, Go, Java, Rust, and Swift.
- JSON/YAML load and save helpers where supported by the target.
- Generated tests and optional compile-only protocol scaffolds.
- Markdown reference output and a JSON contract AST.
- Deterministic
.typra-generatedmetadata for CI review.
Design principle
Section titled “Design principle”Generated code should be useful, reviewable, and replaceable. Typra owns reusable generation behavior; consuming products own domain contracts, runtime orchestration, and adapter logic.