rsnext/packages
Balázs Orbán 79ef1d69ac
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:


![image](https://user-images.githubusercontent.com/18369201/235621140-3df8b10a-b90f-4ec3-b218-066303bfbc73.png)


Closes NEXT-1075
2023-05-03 14:33:51 +02:00
..
create-next-app v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
eslint-config-next v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
eslint-plugin-next v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
font v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next fix(ts): make ReadonlyHeaders more compatible with Headers (#49075) 2023-05-03 14:33:51 +02:00
next-bundle-analyzer v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-codemod v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-env v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-mdx v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-plugin-storybook v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-polyfill-module v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-polyfill-nomodule v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
next-swc v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
react-dev-overlay v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
react-refresh-utils v13.3.5-canary.5 2023-05-03 06:00:23 +00:00