TCGC: Mark types only referenced through external alternate types with External usage in sdkPackage#4236
Merged
iscai-msft merged 7 commits intomainfrom Apr 20, 2026
Conversation
…s and filter out types only used by external types Types that are only referenced through external alternate types (via @alternateType with external type info) should not appear in sdkPackage.models, sdkPackage.enums, or sdkPackage.unions. Changes: 1. In updateUsageOrAccess, stop propagation of non-External usage/access past types with external alternate type. This prevents Input/Output/Json flags from being set on child types of external types. 2. In filterOutTypes, skip types that have External usage but no Input/Output usage, since they are only referenced by external types and don't need to be generated. Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/5be8cb07-aab2-4afa-811a-93c2d85e33fb Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/5be8cb07-aab2-4afa-811a-93c2d85e33fb Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix TCGC to avoid creating types used only in external alternate types
TCGC: Exclude types only referenced through external alternate types from sdkPackage
Apr 10, 2026
tadelesh
reviewed
Apr 13, 2026
Address reviewer feedback: - Move the external type check before any usage/access is set. For external types, only External usage flag can be set; Input/Output/Json and access are blocked, and children are never visited. - Remove the filterOutTypes change since it's now unnecessary: children of external types have zero usage and are naturally filtered out. Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/6b9774c6-28b8-4e22-9dee-3cf9a3195d0f Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Contributor
Author
Both comments addressed in |
commit: |
tadelesh
reviewed
Apr 14, 2026
Allow External usage flag to propagate through children of external types. Add filter in filterOutTypes to exclude children that only have External usage (not external types themselves). Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/063f7216-b104-4160-bfd1-8050847f12c8 Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
tadelesh
reviewed
Apr 14, 2026
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/78c1e8c9-0ab6-44cd-8c01-63f84f589c5e Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Copilot
AI
changed the title
TCGC: Exclude types only referenced through external alternate types from sdkPackage
TCGC: Mark types only referenced through external alternate types with External usage in sdkPackage
Apr 14, 2026
Collaborator
|
All changed packages have been documented.
Show changes
|
Collaborator
|
You can try these changes here
|
iscai-msft
approved these changes
Apr 20, 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 a type has
@@alternateTypewith an external type, child types reachable only through that external type (models, unions) still appeared insdkPackage.models/sdkPackage.unionswith full usage flags (Input, Output, Json, etc.). Emitters had no way to distinguish these from types they actually need to generate.Previously:
Geometryand theFeatureIdunion both appeared in the package withInput | Jsonusage. Now: they remain insdkPackage.models/sdkPackage.unionsbut with onlyExternalusage, allowing emitters to distinguish them from types they need to generate.Changes
Block non-External usage on external types at the beginning of
updateUsageOrAccess(types.ts): When encountering a type withexternalset, onlyUsageFlags.Externalis allowed to be set and propagated. All other usage (Input, Output, Json, etc.) and access propagation are blocked. TheExternalflag itself still propagates to children so they are marked as reachable from external types.Updated tests (
alternate-type.test.ts): Two existing tests updated to assert child types are present ingetAllModels()with onlyExternalusage. New test added covering the exact Geometry/Feature/union scenario from the issue, verifying child types haveExternalusage but noInput/Outputusage.