Skip to content

Commit 2f72427

Browse files
mcanshMichaelDeBoey
authored andcommitted
chore: add TypedResponse generic
Signed-off-by: Logan McAnsh <[email protected]>
1 parent 5e52964 commit 2f72427

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/fetch/src/response.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ export default class Response extends Body {
128128

129129
/**
130130
* @template {unknown} Data
131-
* @param {Data} data The URL that the new response is to originate from.
131+
* @param {Data} data The data to be converted into a JSON string.
132132
* @param {ResponseInit} [responseInit] An optional status code for the response (e.g., 302.)
133-
* @returns {Promise<Data>} A Response object.
133+
* @returns {TypedResponse<Data>} A Response object.
134134
*/
135135
static json(data, responseInit = {}) {
136136
let headers = new Headers(responseInit.headers);
@@ -159,3 +159,9 @@ Object.defineProperties(Response.prototype, {
159159
clone: {enumerable: true}
160160
});
161161

162+
/**
163+
* @typedef {Omit<Response, "json"> & {
164+
* json(): Promise<T>;
165+
* }} TypedResponse
166+
* @template T
167+
*/

0 commit comments

Comments
 (0)