Conversation
… generation Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/843b7d79-a351-4b13-92d2-e0d8de209222
Copilot
AI
changed the title
[WIP] Review comment on emitter type generation from unknown to any
Add Mar 26, 2026
treat-unknown-as-record feature flag to map TypeSpec unknown to Record<string, unknown> in Modular SDK
6 tasks
MaryGao
reviewed
Mar 27, 2026
| return getEnumExpression(context, type); | ||
| case "unknown": | ||
| return "any"; | ||
| return context.rlcOptions?.treatUnknownAsRecord |
Member
There was a problem hiding this comment.
@copilot when the treatUnknownAsRecord is enabled, we should generate noWrap for unknown type. also add an UT for unknow as return type for treatUnknownAsRecord on/off.
Contributor
Author
There was a problem hiding this comment.
Done in commit 6d87a9f. When treatUnknownAsRecord is enabled, checkWrapNonModelReturn now returns noWrap for unknown type (treating it as a Dictionary/Record type, consistent with HLC's PropertyKind.Dictionary → no body wrapper behavior). The return type is Record<string, unknown> directly instead of being wrapped in { body: any }.
Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/a8223ce5-d82c-41df-8443-7df4b0268256 Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com>
MaryGao
approved these changes
Mar 30, 2026
JialinHuang803
approved these changes
Mar 30, 2026
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.
When migrating from HLC to TypeSpec-generated Modular SDKs, TypeSpec
unknownemits asany, but HLC mapped the equivalent swagger type toRecord<string, unknown>. This breaks public API compatibility for migrating services.Changes
treat-unknown-as-record(boolean, Modular only, defaultfalse): when enabled, TypeSpecunknownmaps toRecord<string, unknown>instead ofanyget-type-expression.ts):unknowncase now checkscontext.rlcOptions?.treatUnknownAsRecordto select the output typeoperationHelpers.ts):checkWrapNonModelReturnnow returnsnoWrapforunknowntype whentreatUnknownAsRecordis enabled, treating it as a Dictionary/Record type (consistent with HLC'sPropertyKind.Dictionary → no body wrapperbehavior)EmitterOptions→RLCOptionsSchema→RLCOptions→transfromRLCOptions.tsfollowing the existing pattern used by similar compat flagsemitModularModelsFromTypeSpecandemitModularOperationsFromTypeSpecwired to forward the new optiontreatUnknownAsRecord.mdcovering enabled/disabled flag behavior and the noWrap interaction withwrap-non-model-returnExample
With
treat-unknown-as-record: trueintspconfig.yaml:When combined with
wrap-non-model-return: true, theunknownreturn type is no longer wrapped in a{ body: any }alias — it is returned directly asRecord<string, unknown>:🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.