mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): add type support for router composables without pages/
integration
This commit is contained in:
parent
2518cf8d37
commit
397c54c9db
@ -64,6 +64,14 @@ export default defineNuxtModule({
|
||||
}
|
||||
})
|
||||
|
||||
// adds support for #vue-router alias (used for types) with and without pages integration
|
||||
addTemplate({
|
||||
filename: 'vue-router.d.ts',
|
||||
getContents: () => `export * from '${useExperimentalTypedPages ? 'vue-router/auto' : 'vue-router'}'`
|
||||
})
|
||||
|
||||
nuxt.options.alias['#vue-router'] = join(nuxt.options.buildDir, 'vue-router')
|
||||
|
||||
if (!nuxt.options.pages) {
|
||||
addPlugin(resolve(distDir, 'app/plugins/router'))
|
||||
addTemplate({
|
||||
@ -78,6 +86,12 @@ export default defineNuxtModule({
|
||||
return
|
||||
}
|
||||
|
||||
addTemplate({
|
||||
filename: 'vue-router.mjs',
|
||||
// TODO: use `vue-router/auto` when we have support for page metadata
|
||||
getContents: () => 'export * from \'vue-router\';'
|
||||
})
|
||||
|
||||
if (useExperimentalTypedPages) {
|
||||
const declarationFile = './types/typed-router.d.ts'
|
||||
|
||||
@ -261,17 +275,6 @@ export default defineNuxtModule({
|
||||
}
|
||||
})
|
||||
|
||||
// adds support for #vue-router alias
|
||||
addTemplate({
|
||||
filename: 'vue-router.mjs',
|
||||
// TODO: use `vue-router/auto` when we have support for page metadata
|
||||
getContents: () => 'export * from \'vue-router\';'
|
||||
})
|
||||
addTemplate({
|
||||
filename: 'vue-router.d.ts',
|
||||
getContents: () => `export * from '${useExperimentalTypedPages ? 'vue-router/auto' : 'vue-router'}'`
|
||||
})
|
||||
|
||||
// Add routes template
|
||||
addTemplate({
|
||||
filename: 'routes.mjs',
|
||||
@ -365,8 +368,6 @@ export default defineNuxtModule({
|
||||
filePath: resolve(distDir, 'pages/runtime/page')
|
||||
})
|
||||
|
||||
nuxt.options.alias['#vue-router'] = join(nuxt.options.buildDir, 'vue-router')
|
||||
|
||||
// Add declarations for middleware keys
|
||||
nuxt.hook('prepare:types', ({ references }) => {
|
||||
references.push({ path: resolve(nuxt.options.buildDir, 'types/middleware.d.ts') })
|
||||
|
Loading…
Reference in New Issue
Block a user