fix(ts): make `ReadonlyHeaders` more compatible with `Headers` (#49075)
### What?
Make it possible to pass `headers()` where the `Headers` type is
expected. An example would be `fetch`:
```ts
import { headers } from "next/headers"
// ...
fetch("https://example.com", {
headers: headers()
})
```
### Why?
`ReadonlyHeaders` _currently omits_ some mutating methods which make
sense since they don't make sense. 🙃 . However, it makes
it necessary to pass the result anywhere where `Headers` is expected.
Since we already throw errors when these methods are called illegally,
we can make the type constraint a bit looser to avoid `as any` or
`Object.fromEntries(headers())` or similar.
### How?
Mark the unavailable methods as `@deprecated` which will visually mark
them in IDEs:

Closes NEXT-1075
Showing
Please
register
or
sign in
to comment