Skip to content

[Bug]: http-client-js client options use endpoint when the server parameter has another name #12352

Open

Description

Describe the bug

When the @server parameter is not named endpoint, the options interface still declares endpoint, but the context factory reads the real parameter name from the options. The emitted client does not type-check, and the option cannot be set through the declared type.

Reproduction

Emitted with @typespec/http-client-js (default options).

import "@typespec/http";
using Http;
@service(#{ title: "Repro" })
@server("{baseUrl}", "", { baseUrl?: url = "http://localhost:3000" })
namespace Repro;

@get op read(): void;

Actual:

In src/api/reproClientContext.ts:

export interface ReproClientOptions extends ClientOptions {
  endpoint?: string;
}
// ...
  const params: Record<string, any> = {
    baseUrl: options?.baseUrl ?? "http://localhost:3000"
  };
reproClientContext.ts(15,23): error TS2339: Property 'baseUrl' does not exist on type 'ReproClientOptions'.

Expected: the options interface declares the server parameters by their names (baseUrl?: string).

Versions: @typespec/compiler 1.17.0, @typespec/http 1.17.0, @typespec/http-client-js 0.16.3. Also reproduced with the emitter built from main (721154b).

Checklist

Activity

  1. added
    bugSomething isn't working
    emitter:client:jsIssue for the JS client emitter: @typespec/http-client-js
    on Oct 22, 2026
  2. github-actions commented on Oct 22, 2026

    @github-actions
    Contributor

    🎯 Issue Triage

    The JS client emitter hardcodes endpoint in the generated options interface but reads the actual @server parameter name when constructing request parameters. A custom name such as baseUrl therefore produces invalid TypeScript and cannot be configured through the declared options type.

    Category: Bug

    Area: emitter:client:js

    🔗 [Playground Reproduction]((typespec.io/redacted)

    📋 Reproduction code
    import "@typespec/http";
    using Http;
    @service(#{ title: "Repro" })
    @server("{baseUrl}", "", { baseUrl?: url = "(localhost/redacted) })
    namespace Repro;
    
    @get op read(): void;
    🔍 Analysis

    The affected component is @typespec/http-client-js client-context/options generation. The likely cause is that the options interface generation assumes the conventional endpoint property while context initialization correctly derives baseUrl from server parameter metadata. The two generated surfaces must use the same parameter names. Searches for the error, custom server-parameter names, and endpoint option generation found no strong duplicate.

    📝 Suggested next steps
    • Generate option properties from the declared @server parameters rather than a hardcoded endpoint property.
    • Add an emitter test using a custom server parameter name and verify the emitted client type-checks.

    Generated by Agentic Triage

  3. guishiw commented on Oct 30, 2026

    @guishiw

    Hi, I’d like to work on this issue. I’ve reproduced the problem and completed a proposed fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingemitter:client:jsIssue for the JS client emitter: @typespec/http-client-js

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions