You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 388eecc
Browse filesBrowse the repository at this point in the historyBrowse files
feat(playground): make raw tspconfig.yaml the source of truth with LSP (#11016)
## Problem
The playground "Yaml" config tab (added in #9843) was a **lossy view**
regenerated from the structured `compilerOptions` on every mode/tab
switch. As a result:
- Raw edits — comments, `output-dir`, `warn-as-error`, key ordering, and
any field the visual form doesn't model — were **reverted** when leaving
the editor.
- The editor was a plain `yaml` model with **no LSP**, even though the
TypeSpec language server already supports `tspconfig.yaml` completion.
## Change
Make the raw `tspconfig.yaml` the source of truth.
- **Persistence / no revert** — the raw YAML string is stored in
playground state. `selectedEmitter`/`compilerOptions` are derived by
parsing it; the Visual form and emitter dropdown write back via
`updateTspConfigYaml`, which uses the `yaml` Document API to **preserve
comments and unknown fields**.
- **Native config resolution** — compilation writes `tspconfig.yaml` to
the virtual FS and resolves it via `resolveCompilerOptions`, so the
playground honors the full config (`emit`, `options`, `linter`,
`imports`, `warn-as-error`, …) like the real CLI.
- **LSP** — registered the `yaml` language and a completion provider for
models ending in `tspconfig.yaml`, backed by the language server.
<img width="590" height="379" alt="image"
src="https://github.com/user-attachments/assets/3c57c788-9ca0-436c-aacd-f0ed6476f456"
/>
- **Sharing** — `tspconfig` is persisted in shared links. Legacy
`e=`/`options=` links are still read for back-compat, but only
`tspconfig=` is written on save (stale legacy params are cleared).
## Notes
- The language server does not emit diagnostics for `tspconfig.yaml`
(completion only), so config schema errors aren't shown inline —
consistent with existing server behavior; possible follow-up.
## Tests
- New `tspconfig-utils.test.ts` covers comment/field preservation, emit
removal, rebuild-from-empty, and parsing round-trips.
- All 48 playground tests pass; package builds (type-check) and lint are
clean.
Make the raw `tspconfig.yaml` editor the source of truth so manual edits (comments, `output-dir`, `warn-as-error`, ordering and any unknown fields) are preserved instead of being reverted, compile by resolving the written `tspconfig.yaml` natively, and add language-server completion to the config editor.
0 commit comments