From 7a575974a78dfd597e5cea5d6917ff72befc567d Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 18 Jun 2024 10:10:20 +0200 Subject: [PATCH] feat: make `definePage()` globally available --- client.d.ts | 5 +++++ playground/auto-imports.d.ts | 1 - src/index.ts | 2 +- src/runtime.ts | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client.d.ts b/client.d.ts index 107591b74..9ca4d9293 100644 --- a/client.d.ts +++ b/client.d.ts @@ -32,4 +32,9 @@ declare module 'vue-router/auto' { // export { defineColadaLoader } from 'unplugin-vue-router/data-loaders/pinia-colada' } +// Make the macros globally available +declare global { + const definePage: (typeof import('unplugin-vue-router/runtime'))['definePage'] +} + export {} diff --git a/playground/auto-imports.d.ts b/playground/auto-imports.d.ts index 9788abd64..c1b569ffa 100644 --- a/playground/auto-imports.d.ts +++ b/playground/auto-imports.d.ts @@ -6,7 +6,6 @@ export {} declare global { const defineBasicLoader: typeof import('unplugin-vue-router/data-loaders/basic')['defineBasicLoader'] - const definePage: typeof import('unplugin-vue-router/runtime')['definePage'] const onBeforeRouteLeave: typeof import('vue-router/auto')['onBeforeRouteLeave'] const onBeforeRouteUpdate: typeof import('vue-router/auto')['onBeforeRouteUpdate'] const useRoute: typeof import('vue-router/auto')['useRoute'] diff --git a/src/index.ts b/src/index.ts index 2ba340b2f..68c92dc67 100644 --- a/src/index.ts +++ b/src/index.ts @@ -181,5 +181,5 @@ export const VueRouterAutoImports: Record< // NOTE: the typing seems broken locally, so instead we export it directly from unplugin-vue-router/runtime // 'definePage', ], - 'unplugin-vue-router/runtime': ['definePage'], + 'unplugin-vue-router/runtime': [], } diff --git a/src/runtime.ts b/src/runtime.ts index ebfa53e39..050cd8030 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -13,6 +13,7 @@ export * from './data-loaders' * @deprecated - use `definePage` instead */ export const _definePage = (route: DefinePage) => route + /** * Defines properties of the route for the current page component. *