Unverified Commit 8b0c4e46 authored by Eric Spishak-Thomas's avatar Eric Spishak-Thomas Committed by GitHub

Relax the type on the has/missing type field of the middleware match config. (#72042)

As it is currently with a literal type, this type isn't very useful. As
https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-inference
explains, TypeScript infers these types on middleware configs as
strings, so middleware configs aren't inferred as this type. This can be
fixed by adding `as const` after the string literal, but that is
annoying to do everywhere (it also isn't currently supported by Next.js:
https://github.com/vercel/next.js/blob/89ee26cc76de11c7110dda17389fcfa50c9dbe36/packages/next/src/build/analysis/extract-const-value.ts#L103).
By removing this type restriction, this type will be more useful.

This is safe to do because this type isn't currently being used anywhere
(it never matches) and Next.js already carefully checks/verifies the
type of this middleware config object at build time, so will still find
any issues then.
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent eae26c7d
......@@ -9,7 +9,7 @@ import { isFullStringUrl } from './url'
export type RouteHas =
| {
type: 'header' | 'query' | 'cookie'
type: string
key: string
value?: string
}
......
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