Skip to content

feat(playground): make raw tspconfig.yaml the source of truth with LSP#11016

Merged
timotheeguerin merged 2 commits into
microsoft:mainfrom
timotheeguerin:playground-tspconfig-edit
Jun 19, 2026
Merged

feat(playground): make raw tspconfig.yaml the source of truth with LSP#11016
timotheeguerin merged 2 commits into
microsoft:mainfrom
timotheeguerin:playground-tspconfig-edit

Conversation

@timotheeguerin

@timotheeguerin timotheeguerin commented Jun 18, 2026

Copy link
Copy Markdown
Member

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.
image
  • Sharingtspconfig 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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/playground@11016

commit: bb60c72

The YAML config tab was a lossy view regenerated from structured compiler
options, so raw edits (comments, output-dir, warn-as-error, ordering, unknown
fields) were reverted, and the editor had no language-server support.

- Persist the raw tspconfig.yaml as the source of truth; derive emitter/options
  by parsing it and write back from the Visual form preserving comments/fields.
- Compile by writing tspconfig.yaml and resolving it natively via
  resolveCompilerOptions so the full config is honored.
- Register language-server completion for the tspconfig.yaml editor.
- Persist tspconfig in shared links; keep reading legacy e=/options= links.
@timotheeguerin timotheeguerin force-pushed the playground-tspconfig-edit branch from 24b31f4 to 2abb87c Compare June 18, 2026 15:21
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/playground
Show changes

@typespec/playground - feature ✏️

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.

@timotheeguerin timotheeguerin marked this pull request as ready for review June 18, 2026 15:43
@azure-sdk-automation

azure-sdk-automation Bot commented Jun 18, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin timotheeguerin added this pull request to the merge queue Jun 19, 2026
Merged via the queue into microsoft:main with commit 388eecc Jun 19, 2026
33 checks passed
@timotheeguerin timotheeguerin deleted the playground-tspconfig-edit branch June 19, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants