diff --git a/src/http-api/fetch.ts b/src/http-api/fetch.ts index 4285d9248..33a22b64a 100644 --- a/src/http-api/fetch.ts +++ b/src/http-api/fetch.ts @@ -39,9 +39,9 @@ interface TypedResponse extends Response { json(): Promise; } -export type ResponseType = O extends undefined - ? T - : O extends { onlyData: true } +export type ResponseType = O extends { json: false } + ? string + : O extends { onlyData: true } | undefined ? T : TypedResponse; @@ -371,7 +371,7 @@ export class FetchHttpApi { } if (this.opts.onlyData) { - return json ? res.json() : res.text(); + return (json ? res.json() : res.text()) as ResponseType; } return res as ResponseType; } diff --git a/yarn.lock b/yarn.lock index f1cbac0ac..fdc2d3f46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6383,9 +6383,9 @@ typedoc@^0.27.0: yaml "^2.6.1" typescript@^5.4.2: - version "5.7.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e" - integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw== + version "5.8.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" + integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== uc.micro@^2.0.0, uc.micro@^2.1.0: version "2.1.0"