···48484949The JSON is what you'll publish—typelex just makes authoring easier. Think of it as "CoffeeScript for Lexicon" (however terrible that may be).
50505151-Typelex tries to stay faithful to both TypeSpec idioms and Lexicon concepts, which is a tricky balance. Since we can't add keywords to TypeSpec, decorators fill the gaps—you'll write `@procedure op` instead of `procedure`, or `model` for what Lexicon calls a "def". One downside of this approach is you'll need to learn both Lexicon *and* TypeSpec to know what you're doing. Scan the [TypeSpec language overview](https://typespec.io/docs/language-basics/overview/) to get a feel for it, it isn't much.
5151+Typelex tries to stay faithful to both TypeSpec idioms and Lexicon concepts, which is a tricky balance. Since we can't add keywords to TypeSpec, decorators fill the gaps—you'll write `@procedure op` instead of `procedure`, or `model` for what Lexicon calls a "def". One downside of this approach is you'll need to learn both Lexicon *and* TypeSpec to know what you're doing. Scan the [TypeSpec language overview](https://typespec.io/docs/language-basics/overview/) to get a feel for it.
52525353Personally, I find JSON Lexicons hard to read and author, so the tradeoff works for me.
54545555### Playground
56565757-[Open Playground](https://playground.typelex.org/) to play with a bunch of lexicons and to see how typelex code translates to Lexicon JSON. If you already know Lexicon, you can learn the syntax by just opening the Lexicons you're familiar with.
5757+[Open Playground](https://playground.typelex.org/) to play with a bunch of lexicons and to see how typelex code translates to Lexicon JSON.
5858+5959+If you already know Lexicon, you can learn the syntax by just opening the Lexicons you're familiar with.
58605961## Quick Start
6062···84868587[Try it in the playground](https://playground.typelex.org/?c=aW1wb3J0ICJAdHlwZWxleC9lbWl0dGVyIjsKCm5hbWVzcGFjZSBhcHAuYnNreS5mZWVkLmRlZnMgewogIG1vZGVsIFBvc3RWaWV3xRMgIHJlcGx5Q291bnQ%2FOiBpbnRlZ2VyO8gab3N01RtsaWtl0xl9Cn0K&e=%40typelex%2Femitter&options=%7B%7D&vs=%7B%7D).
86888787-Use backticks for reserved words:
8989+If TypeSpec complains about reserved words in namespaces, use backticks:
88908991```typescript
9092import "@typelex/emitter";
···124126}
125127```
126128127127-Model names convert PascalCase → camelCase:
129129+Model names convert PascalCase → camelCase. For example, `PostView` becomes `postView`:
128130129131```json
130132{
···141143142144### Namespace Conventions: `.defs` vs `Main`
143145144144-By convention, a namespace must either have a `Main` model or end with `.defs`.
146146+By convention, a namespace must either end with `.defs` or have a `Main` model.
145147146148Use `.defs` for a grabbag of reusable definitions:
147149···182184}
183185```
184186185185-This becomes a local `ref`:
187187+This becomes a `ref` to the `caption` definition in the same file:
186188187189```json
188190// ...
189189-"captions": {
190190- "type": "array",
191191- "items": { "type": "ref", "ref": "#caption" }
192192-}
191191+"defs": {
192192+ "main": {
193193+ // ...
194194+ "properties": {
195195+ "captions": {
196196+ // ...
197197+ "items": { "type": "ref", "ref": "#caption" }
198198+ }
199199+ }
200200+ },
201201+ "caption": {
202202+ "type": "object",
203203+ "properties": {}
204204+ }
193205// ...
194206```
195207···209221}
210222```
211223212212-This becomes a fully qualified reference:
224224+This becomes a fully qualified reference to another Lexicon:
213225214226```json
215227// ...