diff --git a/src/http-api/fetch.ts b/src/http-api/fetch.ts index e6728fbd9..b909c3b03 100644 --- a/src/http-api/fetch.ts +++ b/src/http-api/fetch.ts @@ -37,11 +37,17 @@ interface TypedResponse extends Response { json(): Promise; } -export type ResponseType = O extends { json: false } - ? string - : O extends { onlyData: true } | undefined - ? T - : TypedResponse; +/** + * The type returned by {@link FetchHttpApi.request}, etc. + * + * If {@link IHttpOpts.onlyData} is unset or false, then the request methods return a + * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response Response} object, + * which we abstract via `TypedResponse`. Otherwise, we just cast it to `T`. + * + * @typeParam T - The type (specified by the application on the request method) that we will cast the response to. + * @typeParam O - The type of the options object on the {@link FetchHttpApi} instance. + */ +export type ResponseType = O extends { onlyData: true } | undefined ? T : TypedResponse; export class FetchHttpApi { private abortController = new AbortController();