Skip to content

Commit

Permalink
fix(callHandle): narrrow body type to BodyInit
Browse files Browse the repository at this point in the history
(it could be narrower in future 0.6.x releases)
  • Loading branch information
pi0 committed Aug 24, 2022
1 parent d51b4d9 commit 7030004
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/runtime/fetch/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ export function createCall (handle: Handle) {
req.body = context.body || null

return handle(req, res).then(() => {
// TODO: Ensure _data is either of BodyInit (or narrower) types
// Blob | ArrayBUffer | TypedArray | DataView | FormData | ReadableStream | URLSearchParams | String
const r = {
body: res._data || '',
body: res._data as BodyInit || '',
headers: res._headers,
status: res.statusCode,
statusText: res.statusMessage
Expand Down
4 changes: 1 addition & 3 deletions src/runtime/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export function createFetch (call: CallHandle, _fetch = global.fetch) {
}
try {
const r = await call({ url, ...init })
// TODO: Ensure body is either of BodyInit types
// Blob | ArrayBUffer | TypedArray | DataView | FormData | ReadableStream | URLSearchParams | String
return new Response(r.body as any, {
return new Response(r.body, {
status: r.status,
statusText: r.statusText,
headers: Object.fromEntries(Object.entries(r.headers).map(
Expand Down

0 comments on commit 7030004

Please sign in to comment.