Hierarchy nested client support#3163
Merged
qiaozha merged 31 commits intoAzure:mainfrom May 21, 2025
Merged
Conversation
qiaozha
commented
May 12, 2025
qiaozha
commented
May 13, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements hierarchical nested client support across the TypeSpec-TS generator, filtering out individually-initialized children where appropriate and threading a [hierarchy, client] tuple (clientMap) through modular codegen helpers.
- Introduces
InitializedByFlagsfiltering ingetMethodHierarchiesMapand a newgetClientHierarchyMaputility. - Updates
getModularClientOptionsto accept the[hierarchy, client]tuple and adjust subfolder logic. - Refactors all modular emit and build helpers (e.g., operations, subpath indices, client context) to use the new tuple signature.
- Adds a nested-client test configuration and spec under
packages/typespec-test.
Reviewed Changes
Copilot reviewed 62 out of 63 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typespec-ts/src/utils/operationUtil.ts | Filter out individually initialized nested clients in method queue |
| packages/typespec-ts/src/utils/clientUtils.ts | Added getClientHierarchyMap, updated getModularClientOptions |
| packages/typespec-ts/src/modular/* | Propagate [hierarchy, client] through emit/build helper signatures |
| packages/typespec-ts/src/index.ts | Switch emitter flow to iterate getClientHierarchyMap tuples |
| packages/typespec-test/test/nestedClient/* | Add nested client test config and TypeSpec spec |
| .vscode/settings.json | Add formatting settings for TypeSpec files |
Files not reviewed (1)
- common/config/rush/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (3)
packages/typespec-ts/src/utils/operationUtil.ts:568
- [nitpick] The filtering logic for child clients based on
InitializedByFlags.Individuallyis duplicated later in this function. Extract it into a helper (e.g.,getNonIndependentChildren) to reduce duplication and improve readability.
client.children?.filter((p) => {
packages/typespec-ts/src/modular/buildProjectFiles.ts:38
- [nitpick] Destructure the tuple directly for clarity. For example:
for (const [hierarchy, client] of clientMap) {
// use `client` directly
}for (const flattenedClient of clientMap) {
packages/typespec-test/test/nestedClient/spec/main.tsp:1
- You’ve added a nested client spec, but there’s no assertion or test verifying the actual generated code for nested clients. Consider adding an end-to-end test that inspects the generated folder structure and client hierarchy to catch any regressions.
import "@typespec/http";
lirenhe
approved these changes
May 16, 2025
MaryGao
reviewed
May 16, 2025
MaryGao
reviewed
May 16, 2025
MaryGao
reviewed
May 16, 2025
MaryGao
reviewed
May 16, 2025
MaryGao
approved these changes
May 20, 2025
Member
MaryGao
left a comment
There was a problem hiding this comment.
Approved and please resolve any left small comments!
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 #2887
fixes #2612
implementation of the hierarchy nested clients. See design doc here