Skip to content

Commit

Permalink
qualify the type name with globalThis to avoid name conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
fredr committed Jan 20, 2025
1 parent 0ef6f05 commit 2d090d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions e2e-tests/testdata/echo_client/ts/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export namespace di {
await this.baseClient.callAPI("POST", `/di/one`)
}

public async Three(method: string, body?: BodyInit, options?: CallParameters): Promise<Response> {
public async Three(method: string, body?: BodyInit, options?: CallParameters): Promise<globalThis.Response> {
return this.baseClient.callAPI(method, `/di/raw`, body, options)
}

Expand Down Expand Up @@ -648,7 +648,7 @@ export namespace test {
* RawEndpoint allows us to test the clients' ability to send raw requests
* under auth
*/
public async RawEndpoint(method: "PUT" | "POST" | "DELETE" | "GET", id: string[], body?: BodyInit, options?: CallParameters): Promise<Response> {
public async RawEndpoint(method: "PUT" | "POST" | "DELETE" | "GET", id: string[], body?: BodyInit, options?: CallParameters): Promise<globalThis.Response> {
return this.baseClient.callAPI(method, `/raw/blah/${id.map(encodeURIComponent).join("/")}`, body, options)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/clientgen/testdata/goapp/expected_typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export namespace svc {
return await resp.json() as Tuple<boolean, Foo>
}

public async Webhook(method: string, a: string, b: string[], body?: BodyInit, options?: CallParameters): Promise<Response> {
public async Webhook(method: string, a: string, b: string[], body?: BodyInit, options?: CallParameters): Promise<globalThis.Response> {
return this.baseClient.callAPI(method, `/webhook/${encodeURIComponent(a)}/${b.map(encodeURIComponent).join("/")}`, body, options)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/clientgen/typescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (ts *typescript) writeService(svc *meta.Service, p clientgentypes.ServiceSe
} else if rpc.ResponseSchema != nil {
ts.writeTyp(ns, rpc.ResponseSchema, 0)
} else if rpc.Proto == meta.RPC_RAW {
ts.WriteString("Response")
ts.WriteString("globalThis.Response")
} else {
ts.WriteString("void")
}
Expand Down

0 comments on commit 2d090d2

Please sign in to comment.