Skip to content

Add diagnostic metadata to @experimental - #11684

Merged
JoshLove-msft merged 2 commits into
microsoft:mainfrom
JoshLove-msft:josh/experimental-diagnostic-id
Aug 17, 2026
Merged

Add diagnostic metadata to @experimental#11684
JoshLove-msft merged 2 commits into
microsoft:mainfrom
JoshLove-msft:josh/experimental-diagnostic-id

Conversation

@JoshLove-msft

@JoshLove-msft JoshLove-msft commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Motivation

@experimental currently records only that a TypeSpec declaration is experimental. That is enough for emitters that need a boolean lifecycle flag, but it does not describe how an emitter should identify the experiment or whether the generated implementation relies on other experimental features.

A generated API can be a distinct public experiment while being composed from several lower-level experiments. For example, an operation tracked as experiment C may internally use experimental features A and B. Consumers should see C, while an emitter may need A and B to generate warning suppressions around implementation code.

Usage

@experimental(#{
  emitterScope: "@typespec/http-client-csharp",
  diagnosticId: "C",
  dependsOn: #["A", "B"]
})
op bar(): void;

Scenarios

  • Direct experiment: specify only diagnosticId when an emitter needs a stable identifier for the experimental API.
  • Composed experiment: use dependsOn when the generated implementation consumes other independently experimental features.
  • Emitter-specific diagnostics: use emitterScope when identifiers are meaningful only to a particular emitter or target language.
  • Lifecycle tooling: emitters and tooling can query the complete lifecycle details without parsing decorator syntax.
  • Explicit graduation: dependencies becoming generally available does not silently graduate the public API. The declaration remains experimental until its decorator is explicitly removed.

API changes

  • Add optional diagnosticId and dependsOn fields to FeatureLifecycleOptions.
  • Add getFeatureLifecycleDetails, returning:
{
  stage: "Experimental";
  diagnosticId?: string;
  dependsOn: readonly string[];
}
  • Preserve the existing getFeatureLifecycle API and its "Experimental" | undefined behavior for compatibility.
  • Apply existing emitter-scope filtering to all lifecycle details.

Emitter behavior

The metadata is descriptive rather than prescriptive. Each emitter decides how to represent it. The C# companion implementation in #11685 maps diagnosticId to ExperimentalAttribute and dependsOn to scoped warning suppressions.

Related work

Validation

  • @typespec/http-client build and full test suite
  • Affected-package lint and formatting checks

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f0e7f0ac-c4b6-47e3-a4fc-430ff8f883c6
@pkg-pr-new

pkg-pr-new Bot commented Aug 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client@11684

commit: d301a81

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client
Show changes

@typespec/http-client - feature ✏️

Add diagnostic and dependency metadata to @experimental.,> ,> typespec,> @experimental(#{ diagnosticId: "C", dependsOn: #["A", "B"] }),> op bar(): void;,>

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@JoshLove-msft
JoshLove-msft added this pull request to the merge queue Aug 17, 2026
Merged via the queue into microsoft:main with commit d3cdadd Aug 17, 2026
33 checks passed
@JoshLove-msft
JoshLove-msft deleted the josh/experimental-diagnostic-id branch August 17, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants