Skip to content

Commit

Permalink
fix(ts): mark .getAll() as optional (vercel#262)
Browse files Browse the repository at this point in the history
* fix(ts): mark `.getAll` as optional

* add changelog
  • Loading branch information
balazsorban44 authored and jridgewell committed Jun 23, 2023
1 parent aaaa759 commit 085cd3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/twenty-dancers-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@edge-runtime/node-utils': patch
'@edge-runtime/primitives': patch
---

We are already falling back in code, the types just need to reflect this correctly
4 changes: 1 addition & 3 deletions packages/node-utils/src/edge-to-node/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ export function toOutgoingHeaders(
outputHeaders[name] = value
if (name.toLowerCase() === 'set-cookie') {
outputHeaders[name] =
'getAll' in headers
? headers.getAll('set-cookie')
: splitCookiesString(value)
headers.getAll?.('set-cookie') ?? splitCookiesString(value)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/primitives/type-definitions/fetch.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class Headers extends globalThis.Headers {
getAll(key: 'set-cookie'): string[]
getAll?(key: 'set-cookie'): string[]
}

export class Request extends globalThis.Request {
Expand Down

0 comments on commit 085cd3a

Please sign in to comment.