mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 13:15:12 +00:00
fix(nuxt): do not accept arbitrary strings for MiddlewareKey
(#28676)
This commit is contained in:
parent
ae8cc86483
commit
0a4113571d
@ -1,16 +1,21 @@
|
||||
// For pnpm typecheck:docs to generate correct types
|
||||
|
||||
import { addPluginTemplate } from 'nuxt/kit'
|
||||
import { addPluginTemplate, addRouteMiddleware } from 'nuxt/kit'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
typescript: { shim: process.env.DOCS_TYPECHECK === 'true' },
|
||||
pages: process.env.DOCS_TYPECHECK === 'true',
|
||||
modules: [
|
||||
function () {
|
||||
if (!process.env.DOCS_TYPECHECK) { return }
|
||||
addPluginTemplate({
|
||||
filename: 'plugins/my-plugin.mjs',
|
||||
getContents: () => 'export default defineNuxtPlugin({ name: \'my-plugin\' })',
|
||||
})
|
||||
addRouteMiddleware({
|
||||
name: 'auth',
|
||||
path: '#build/auth.js',
|
||||
})
|
||||
},
|
||||
],
|
||||
})
|
||||
|
@ -510,7 +510,7 @@ export default defineNuxtModule({
|
||||
const namedMiddleware = app.middleware.filter(mw => !mw.global)
|
||||
return [
|
||||
'import type { NavigationGuard } from \'vue-router\'',
|
||||
`export type MiddlewareKey = ${namedMiddleware.map(mw => genString(mw.name)).join(' | ') || 'string'}`,
|
||||
`export type MiddlewareKey = ${namedMiddleware.map(mw => genString(mw.name)).join(' | ') || 'never'}`,
|
||||
`declare module ${genString(composablesFile)} {`,
|
||||
' interface PageMeta {',
|
||||
' middleware?: MiddlewareKey | NavigationGuard | Array<MiddlewareKey | NavigationGuard>',
|
||||
|
Loading…
Reference in New Issue
Block a user