Skip to content

Commit ca1ad12

Browse files
Generate index files for nested clients (#3734)
* Initial plan * Add expected blob/index.ts file to demonstrate the fix Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com> * Smoke test passed with blob/index.ts Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com> * All tests passing - fix complete Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com> * Simplify condition check as per code review feedback Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com> * Fix naming consistency for exported types in blob/index.ts * Add clarifying comment for subfolder condition check Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com> * Address PR feedback: revert manual changes and simplify condition Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JialinHuang803 <139532647+JialinHuang803@users.noreply.github.com>
1 parent 37ae257 commit ca1ad12

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

  • packages
    • typespec-test/test/nestedClient/generated/typespec-ts/src/blob
    • typespec-ts/src
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
export { BlobClient } from "./blobClient.js";
5+
export { BlobContext, BlobClientOptionalParams, DownloadOptionalParams } from "./api/index.js";

packages/typespec-ts/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ import { emitLoggerFile } from "./modular/emitLoggerFile.js";
9191
import { emitTypes } from "./modular/emitModels.js";
9292
import { existsSync } from "fs";
9393
import { getModuleExports } from "./modular/buildProjectFiles.js";
94-
import { getClientHierarchyMap, getRLCClients } from "./utils/clientUtils.js";
94+
import {
95+
getClientHierarchyMap,
96+
getRLCClients,
97+
getModularClientOptions
98+
} from "./utils/clientUtils.js";
9599
import { join } from "path";
96100
import { loadStaticHelpers } from "./framework/load-static-helpers.js";
97101
import { packageUsesXmlSerialization } from "./modular/serialization/buildXmlSerializerFunction.js";
@@ -319,7 +323,6 @@ export async function $onEmit(context: EmitContext) {
319323
}
320324
);
321325

322-
const isMultiClients = dpgContext.sdkPackage.clients.length > 1;
323326
emitTypes(dpgContext, { sourceRoot: modularSourcesRoot });
324327
buildSubpathIndexFile(modularEmitterOptions, "models", undefined, {
325328
recursive: true
@@ -353,7 +356,9 @@ export async function $onEmit(context: EmitContext) {
353356
exportIndex: true,
354357
interfaceOnly: true
355358
});
356-
if (isMultiClients) {
359+
const { subfolder } = getModularClientOptions(subClient);
360+
// Generate index file for clients with subfolders (multi-client scenarios and nested clients)
361+
if (subfolder) {
357362
buildSubClientIndexFile(dpgContext, subClient, modularEmitterOptions);
358363
}
359364
buildRootIndex(

0 commit comments

Comments
 (0)