[client-generator-core] Allow @clientOption value to reference a TypeSpec model - #5276
Merged
Chenjie Shi (tadelesh) merged 6 commits intoAug 21, 2026
Conversation
Extends the @clientoption decorator so its value parameter can accept a reference to a TypeSpec model, in addition to the previously supported string, boolean, and number literal values. The referenced model is resolved through TCGC's type conversion pipeline, preserving any customizations (such as @alternateType) so scoped emitters can resolve the referenced model via getClientOptions. Fixes Azure#5256 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
iscai-msft
requested review from
Laurent Mazuel (lmazuel),
m-nash,
Mark Cowlishaw (markcowl),
Timothee Guerin (timotheeguerin) and
Jeff Fisher (xirzec)
as code owners
August 20, 2026 16:49
…ions-model-values # Conflicts: # packages/typespec-client-generator-core/generated-defs/Azure.ClientGenerator.Core.ts # packages/typespec-client-generator-core/lib/decorators.tsp
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
Contributor
📦 Package size report✅ No notable package size changes compared to the base branch. 13 package(s) with no notable change
Packed = gzipped |
iscai-msft
commented
Aug 20, 2026
Contributor
|
You can try these changes here
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 43cc5590-eb34-4c28-bdcd-36f6365474be
Chenjie Shi (tadelesh)
approved these changes
Aug 21, 2026
Keep the kebab-case emitter option access required by the current Options type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 43cc5590-eb34-4c28-bdcd-36f6365474be
Chenjie Shi (tadelesh)
requested review from
Heath Stewart (heaths),
Joel Hendrix (jhendrixMSFT) and
Renhe Li (lirenhe)
as code owners
August 21, 2026 03:11
github-actions Bot
added a commit
to jhendrixMSFT/typespec-azure
that referenced
this pull request
Aug 21, 2026
- Add emit-content-type-header emitter option to typespec-go reference docs - Update @clientoption decorator docs: signature now accepts model references (value: unknown | valueof unknown), updated parameter descriptions and added example for model reference usage - Update 12clientOptions.mdx: reflect new getClientOptions API (takes SDK type and option name, returns single value), add structured value type example, update scope description to mention decorator-requires-scope warning - Update 04method.mdx: document that @convenientAPI and @protocolAPI require a language scope (java/csharp) and produce decorator-requires-scope warning if omitted Reflects upstream changes from Azure/typespec-azure: - Azure#5261: Add emit-content-type-header emitter option - Azure#5276: Allow @clientoption value to reference a TypeSpec model - Azure#5119: Add decorator-requires-scope validation for @convenientAPI and @clientoption - Azure#5267: Update language scope and overload guidance Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot
added a commit
to l0lawrence/typespec-azure
that referenced
this pull request
Aug 21, 2026
- typespec-go: add emit-content-type-header emitter option (Azure#5261) - TCGC decorators.md: update @clientoption value type to support model references (Azure#5276) - TCGC guideline.md: clarify generate-convenience/protocol-methods scope warning (Azure#5267) - howtos/04method.mdx: update protocol/convenience method scoping guidance (Azure#5267) - howtos/03client.mdx: add note about operation name uniqueness requirements (Azure#5267) - howtos/12clientOptions.mdx: update @clientoption value type and scope documentation (Azure#5267) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
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.
Fixes #5256
Summary
Extends the
@clientOptiondecorator so itsvalueparameter can reference a TypeSpec model, in addition to the previously supportedstring,boolean, andnumberliteral values.Changes
lib/decorators.tsp: updated@clientOption'svalueparameter type tounknown | valueof unknownand added an example/description covering model reference values.src/internal-utils.ts:getDecoratorArgValuenow routesModelkind decorator arguments throughgetClientTypeWithDiagnostics(same path already used forEnumMember), so a referenced model is resolved into itsSdkType, preserving any customizations such as@alternateType.generated-defs/Azure.ClientGenerator.Core.ts: regenerated viapnpm gen-extern-signature.test/decorators/client-option.test.tscovering:value, verified viagetClientOptions.@alternateTypecustomizations on the referenced model are preserved when resolving the value.Testing
pnpm vitest runinpackages/typespec-client-generator-core— 1405 passed, 2 skipped.pnpm buildandpnpm lintpass.Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com