npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@typra/emitter

v0.3.4

Published

Generic TypeSpec emitter for generating multi-runtime model surfaces

Readme

@typra/emitter

@typra/emitter generates runtime model surfaces from TypeSpec. Use it when you want TypeSpec to be the source of truth for shared model contracts and need generated code, tests, JSON AST output, or documentation for one or more runtimes.

Typra is emitter-only: it generates model/protocol surfaces, but it does not ship runtime service implementations or product-specific contracts.

Install

npm install --save-dev @typra/emitter @typespec/[email protected] @typespec/[email protected]

Typra currently validates against TypeSpec compiler and JSON schema emitter 1.10.0. Unvalidated TypeSpec versions report a clear diagnostic during emit; set allow-unsupported-typespec-version: true only when you intentionally accept possible generated output churn.

0.3.0 release highlights

0.3.0 adds Java as a generated runtime target and expands executable fixture confidence across the supported languages:

  • Java model emission with load, save, fromJson, toJson, provider wire mapping, scalar coercion, enum handling, and polymorphic dispatch support.
  • Generated Java fixture tests that compile and run during fixture validation.
  • Stronger Go fixture tests and runtime behavior for scalar slices, JSON round-trips, polymorphic values, and malformed JSON handling.
  • Executable cross-language fixture conformance across TypeScript, Python, C#, Go, Java, and Rust.
  • CI setup for Go and Java toolchains.

Configure TypeSpec

Add the emitter to tspconfig.yaml:

emit:
  - "@typra/emitter"

options:
  "@typra/emitter":
    emitter-output-dir: "{cwd}/generated"
    root-object: "MyProject.ApiRoot"
    root-namespace: "MyProject"
    emit-targets:
      - type: TypeScript
        output-dir: "generated/typescript"
        test-dir: "generated/typescript/tests"
        import-path: "../index"

Import the emitter library from your TypeSpec entry point:

import "@typra/emitter";

namespace MyProject;

Compile with TypeSpec:

npx tsp compile ./path/to/main.tsp --config ./tspconfig.yaml

CLI

The package includes typra-generate, typra-verify, and a generic typra-consumer-smoke harness:

npx typra-generate --help
npx typra-generate --deterministic -o ./generated
npx typra-verify --baseline ./baseline --current ./generated
npx typra-consumer-smoke --config ./typra-smoke.json

typra-verify compares committed .typra-generated metadata against current generated metadata and prints deterministic review summaries for exports, protocols, files, package/module identity, toolchain, protected paths, schema evolution, stale cleanup dry-runs, hydration seams, and breaking-change classification. It never deletes files.

Supported output

Typra includes emitters for:

  • TypeScript
  • Python
  • C#
  • Go
  • Java
  • Rust
  • Markdown documentation
  • JSON AST

The Typra fixture slice validates TypeScript, Python, C#, Go, Java, Rust, Markdown, and JSON AST generation from synthetic TypeSpec shapes. Fixture validation also exercises generated metadata, verifier CLI output, consumer smoke wiring, and cross-language generated-code compile/test surfaces.

Generated files

Generated source files include Typra markers, and the emitter records a generated-file manifest for each output root. Stale-file deletion is not enabled yet, so Typra will not remove hand-authored runtime files.

For CI or committed generated output, enable deterministic metadata with the TypeSpec emitter option:

options:
  "@typra/emitter":
    deterministic-output: true

This keeps .typra-generated/manifest.json stable across equivalent generations by replacing wall-clock generatedAt values with a fixed timestamp. Generated text artifacts are also normalized to LF line endings, trimmed trailing whitespace, and final newlines. Blank generated artifacts are skipped unless the file format requires an empty sentinel such as Python py.typed.

Each generation also writes .typra-generated/report.json, a stable single-run report that lists emitted files, skipped empty outputs, marker-owned stale files removed during skipped-output cleanup, preserved unmarked skipped files, hygiene policy, and warnings. Baseline-aware checks such as protected-path touches remain in typra-verify, and per-file formatter status is not recorded yet.

Rust targets can opt into case-insensitive string-union/enum parsing without changing the default case-sensitive behavior:

emit-targets:
  - type: Rust
    output-dir: generated/rust
    enum-parsing: case-insensitive

When enabled, generated Rust from_str_opt methods accept enum values with ASCII case differences while preserving the canonical serialized casing.

Consumers can declare hand-authored boundaries in verifier config:

{
  "protectedPaths": ["src/adapters/**"],
  "hydrationZones": ["src/extensions/**"]
}

The emitter records hydration seam metadata for generated protocol adapters, but runtime behavior remains hand-authored by the consuming project.

Links