An experimental TypeSpec syntax for Lexicon
57
fork

Configure Feed

Select the types of activity you want to include in your feed.

you're working on a TypeSpec emitter for atproto lexicons. you have these commands: pnpm run build builds the example (you can inspect the generated lexicons in the packages/example/lexicon) and pnpm test runs tests (they are in packages/emitter/test/).

what i want you to do is to gradually keep adding features to typelex so that in the end it's possible to express all Lexicon code with that language. you have the following resources:

  • read DOCS.md!!! it's the main guideline

  • ../typespec/packages has a bunch of other emitters (so you can check how they're implemented and common patterns)

  • ../typespec/website/src/content has typescpec docs (which you might find very useful)

  • ../atproto-website/src/app/[locale]/specs/lexicon contains lexicon spec (where we want to reach feature parity), and most importantly

  • test/scenarios/atproto/output contains a TON of lexicon definitions which i want you to translate to typespec one by one. for each atproto lexicon you're porting, your job is to create the corresponding "inputs" for them (and fix bugs or add missing features along the way).

the goal is to end up with a language that feels nice and concise, not some weird interop thing. so try to do things "typespec" way as you go through each lexicon. and try to respect atproto too. this should feel like a language for atproto. consider whether your design is elegant. and make sure to look at other typespec emitters for design ideas!

remember NOT to change the output to fit the input -- your job is to make the input MATCH the output. if some lexicon is too hard, you can give up on it and try another one. good luck!

the workflow is: pick some new lexicons, create the input files, figure out missing features / bugs, and try to get tests to pass. repeat. when you make nontrivial progress, you'll want to prepare a commit.

before you want to make a commit, make sure pnpm test and pnpm run build passes and, ideally, inspect the example app output (and maybe add the features you've just implemented there for parity). then stop and notify me.

ps. be mindful of the code style. we only put decorators on same line if it's @required alone; otherwise, put each on newline and add a newline after. see existing files for a hint.

good luck! i believe in you


whenever you get stuck (try npm test) because you don't have a convention for how to define some pattern yetm i want you to read these sources

  • ../typespec/packages has a bunch of other emitters (so you can check how they're implemented and common patterns)

  • ../typespec/website/src/content has typescpec docs (which you might find very useful)

  • ../atproto-website/src/app/[locale]/specs/lexicon contains lexicon spec

and ultrathink about what's the most appropriate way to define defs like you want would be in this typespec translation of atproto. you can research these sources for what feels most idiomatic to define that syntax, and how to make the formatter understand that convention and emit the JSON we want.

also note that you can always look at generated atproto lexicons in ../atproto/lexicons -- use these!! look at the TS types there for corresponding models to inspire how you represent things in tsp syntax.

  • read DOCS.md!!! it's the main guideline