Describe the bug
@typespec/http-client-js emits private context fields for generated clients that have no operations. Those fields are initialized but never read. A consumer that enables TypeScript noUnusedLocals cannot compile the generated client because TypeScript reports TS6133 for each field.
This is specific to the JavaScript client emitter. It is related to, but distinct from, #8479, which is scoped to the C# client emitter.
Reproduction
The following public TypeSpec project reproduces the issue:
https://github.com/yoskeoka/ai-arena/tree/f41393621ba220d01a1841e523e11b34c573c938/typespec
From the repository root:
pnpm --dir typespec install
pnpm --dir typespec run build
pnpm --dir operator-ui install --frozen-lockfile
pnpm --dir operator-ui run build
The TypeSpec service emits empty AiArenaClient and SharedClient classes. The generated
operator-ui/src/generated/operator-api/src/aiArenaClient.ts contains equivalent output to:
export class AiArenaClient {
#context: AiArenaClientContext;
constructor(endpoint: string, options?: AiArenaClientOptions) {
this.#context = createAiArenaClientContext(endpoint, options);
// ... subclients
}
}
export class SharedClient {
#context: SharedClientContext;
constructor(endpoint: string, options?: SharedClientOptions) {
this.#context = createSharedClientContext(endpoint, options);
}
}
Neither #context field is read. The final command fails with:
src/generated/operator-api/src/aiArenaClient.ts(...): error TS6133: '#context' is declared but its value is never read.
The service TypeSpec source and generated-client configuration are at the linked revision. The
consumer enables noUnusedLocals in operator-ui/tsconfig.app.json.
Versions
The issue reproduces with the current npm stable release line tested on 2026-09-16:
@typespec/compiler, @typespec/http, @typespec/openapi3: 1.16.0
@typespec/rest: 0.86.0
@typespec/http-client-js: 0.16.2
- generated runtime:
@typespec/ts-http-runtime: 0.3.9
It also reproduces with the project's previous pins (1.13.0 / 0.83.0 / 0.15.0 / 0.2.1).
Expected behavior
The JS emitter should generate strict-TypeScript-safe output for clients with no operations.
For example, it could omit the unused context state and imports, omit empty clients where that is
compatible with the generated API, or otherwise reference the created context. Consumers should
not need to weaken noUnusedLocals or permanently hand-edit generated artifacts.
Describe the bug
@typespec/http-client-jsemits private context fields for generated clients that have no operations. Those fields are initialized but never read. A consumer that enables TypeScriptnoUnusedLocalscannot compile the generated client because TypeScript reportsTS6133for each field.This is specific to the JavaScript client emitter. It is related to, but distinct from, #8479, which is scoped to the C# client emitter.
Reproduction
The following public TypeSpec project reproduces the issue:
https://github.com/yoskeoka/ai-arena/tree/f41393621ba220d01a1841e523e11b34c573c938/typespec
From the repository root:
The TypeSpec service emits empty
AiArenaClientandSharedClientclasses. The generatedoperator-ui/src/generated/operator-api/src/aiArenaClient.tscontains equivalent output to:Neither
#contextfield is read. The final command fails with:The service TypeSpec source and generated-client configuration are at the linked revision. The
consumer enables
noUnusedLocalsinoperator-ui/tsconfig.app.json.Versions
The issue reproduces with the current npm stable release line tested on 2026-09-16:
@typespec/compiler,@typespec/http,@typespec/openapi3:1.16.0@typespec/rest:0.86.0@typespec/http-client-js:0.16.2@typespec/ts-http-runtime:0.3.9It also reproduces with the project's previous pins (
1.13.0/0.83.0/0.15.0/0.2.1).Expected behavior
The JS emitter should generate strict-TypeScript-safe output for clients with no operations.
For example, it could omit the unused context state and imports, omit empty clients where that is
compatible with the generated API, or otherwise reference the created context. Consumers should
not need to weaken
noUnusedLocalsor permanently hand-edit generated artifacts.