next.js
8b0c4e46 - Relax the type on the has/missing type field of the middleware match config. (#72042)

Commit
1 year ago
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: JJ Kasper <jj@jjsweb.site>
Author
Parents
Loading