An experimental TypeSpec syntax for Lexicon
README.md

@typelex/cli#

Experimental CLI for typelex

Installation#

pnpm add -D @typelex/cli @typelex/emitter

Usage#

typelex compile xyz.statusphere.*

This command:

  1. Scans lexicons/ for all external lexicons (not matching xyz.statusphere)
  2. Generates typelex/externals.tsp with @external stubs
  3. Compiles typelex/main.tsp to lexicons/ (or custom output via --out)

Fixed paths:

  • Entry point: typelex/main.tsp
  • Externals: typelex/externals.tsp

Example#

// typelex/main.tsp
import "@typelex/emitter";
import "./externals.tsp";

namespace xyz.statusphere.defs {
  model StatusView {
    @required uri: atUri;
    @required status: string;
    @required profile: app.bsky.actor.defs.ProfileView;
  }
}
typelex compile 'xyz.statusphere.*'

The CLI scans lexicons/ for external types and auto-generates typelex/externals.tsp with stubs

Integration#

{
  "scripts": {
    "build:lexicons": "typelex compile 'xyz.statusphere.*'",
    "build:codegen": "lex gen-server --yes ./src lexicons/xyz/statusphere/*.json"
  }
}

Options#

  • --out <directory> - Output directory for generated Lexicon files (default: ./lexicons)
  • --watch - Watch mode for continuous compilation

License#

MIT