Unverified Commit 8a6e71a4 authored by Dulmandakh's avatar Dulmandakh Committed by GitHub

fix: NextConfig.rewrites type for fallback (#75784)

### What?

Below is a snippet for [Incremental adoption of
Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites#incremental-adoption-of-nextjs)
configuration.

```typescript
module.exports = {
  async rewrites() {
    return {
      fallback: [
        {
          source: '/:path*',
          destination: `https://custom-routes-proxying-endpoint.vercel.app/:path*`,
        },
      ],
    }
  },
}
```

But `rewrites` in `NextConfig` type requires `beforeFiles` and
`afterFiles` besides `fallback`, which makes above configuration invalid
for TypeScript.

### Why?

I assume snippets from official documentation must work.

### How?

This PR makes `beforeFiles` and `afterFiles` optional.

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent a2cba246
......@@ -734,9 +734,9 @@ export interface NextConfig extends Record<string, any> {
rewrites?: () => Promise<
| Rewrite[]
| {
beforeFiles: Rewrite[]
afterFiles: Rewrite[]
fallback: Rewrite[]
beforeFiles?: Rewrite[]
afterFiles?: Rewrite[]
fallback?: Rewrite[]
}
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment