-
Notifications
You must be signed in to change notification settings - Fork 306
Introduce @experimental decorator to tag client-side features #8086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joheredi
wants to merge
13
commits into
microsoft:main
Choose a base branch
from
joheredi:joheredi/feature-lifecycle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All changed packages have been documented.
Show changes
|
You can try these changes here
|
434ccbd
to
15e40ba
Compare
eadebd9
to
ecc281b
Compare
chrisradek
reviewed
Aug 18, 2025
.chronus/changes/joheredi-feature-lifecycle-2025-7-1-14-16-12.md
Outdated
Show resolved
Hide resolved
chrisradek
approved these changes
Aug 19, 2025
9e2a4aa
to
5061a17
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduce
@experimental
decorator to tag client-side featuresObjective
Define a decorator,
@experimental
, that lets TypeSpec authors mark client-side features as experimental. This enables shipping preview helpers, gathering feedback, and promoting features without affecting the service contract version.Goals
@experimental
with minimal syntax.Non-Goals
@typespec/versioning
.Motivation
@typespec/versioning
tracks service API versions only. SDK teams commonly add higher-level helpers (batching, pagination convenience, analytics wrappers) after the REST surface is GA. Without a standard way to tag those as “experimental,” teams patch generated code manually—costly and inconsistent. A formal decorator:User Benefits
Design Proposal
Decorator
Name:
@experimental
Signature
emitterScope
(optional): opaque string used by emitters as a lookup key (e.g.,"typescript"
,"java"
). If omitted, it applies to all emitters.Examples
Lifecycle model & semantics
FeatureLifecycle:
'stable' | 'experimental'
.Default: if
@experimental
is absent →'stable'
.Scope rules:
@experimental
has noemitterScope
, the target is experimental for all emitters.emitterScope
is present, the target is experimental only when the consuming emitter’s scope matches that string. Otherwise it is treated as stable for that emitter.@experimental
with different scopes may be used on the same target; a match on any one marks it experimental for that scope.No inheritance: there is no implicit propagation. Applying
@experimental
to a namespace/interface does not make children experimental. Emitters may choose to layer their own inheritance logic, but it is not part of this spec.No wire-protocol impact: purely metadata; does not change HTTP behavior.
Discovery API
A small helper will be provided for emitters/tooling:
@typespec/http-client
) and re-exported from the client generator core (TCGC) for convenience.'experimental'
if any matching@experimental
applies for the provided scope; otherwise'undefined'
.Guidance for emitters (non-normative)
Emitters can adopt one or more patterns:
Package splitting
Generate experimental items into a preview package or sub-namespace (e.g.,
foo-client-preview
).Constructor opt-in
Provide a client option such as
enablePreviewFeatures: string[]
and surface experimental operations only when opted in.Conditional compilation
Use language-specific flags (e.g.,
#if PREVIEW_FEATURES
in C#,cfg(feature = "preview")
in Rust).Documentation signals
Add doc comments/annotations understood by the ecosystem (e.g., TypeDoc tags, Kotlin opt-in annotations, .NET
RequiresPreviewFeaturesAttribute
) to clearly label experimental APIs.Alternatives Considered
@previewVersion
: conflates client maturity with service versioning.@featureLifecycle
(broader enum): more general but no concrete need today; adds complexity vs. a targeted@experimental
.Performance Implications
Dependencies
@typespec/http-client
(and re-exported by TCGC for emitter use).Engineering Impact
@experimental
and exposegetFeatureLifecycle
.Best Practices
@experimental
early.Compatibility
User Impact
FAQ
Q: Why mark a client helper as experimental if the service is already GA?
A: Client helpers (batching, pagination, analytics, etc.) often evolve after the REST API is GA. Marking them experimental lets you ship safely alongside stable features while you validate design and gather feedback.
Q: Why not mark the service/API as preview instead?
A: Service/API versioning (
@typespec/versioning
) governs the HTTP contract.@experimental
is strictly for client SDK features, so you can ship preview helpers without bumping the service version or impacting existing clients.Q: Can I release experimental client APIs without bumping my package version?
A: Yes. Emitters can gate experimental items behind flags or generate them into preview sub-packages/namespaces, while keeping the main package version unchanged.