diff --git a/packages/nuxt/src/pages/runtime/composables.ts b/packages/nuxt/src/pages/runtime/composables.ts index 78ff8e1454..3fde4c6ccb 100644 --- a/packages/nuxt/src/pages/runtime/composables.ts +++ b/packages/nuxt/src/pages/runtime/composables.ts @@ -14,7 +14,7 @@ export interface PageMeta { * statusCode/statusMessage to respond immediately with an error (other matches * will not be checked). */ - validate?: (route: RouteLocationNormalized) => boolean | Promise | Partial | Promise> + validate?: (route: RouteLocationNormalized) => boolean | Partial | Promise> /** * Where to redirect if the route is directly matched. The redirection happens * before any navigation guard and triggers a new navigation with the new diff --git a/test/fixtures/basic-types/types.ts b/test/fixtures/basic-types/types.ts index 74d9868a90..c0b3f28d55 100644 --- a/test/fixtures/basic-types/types.ts +++ b/test/fixtures/basic-types/types.ts @@ -116,6 +116,21 @@ describe('middleware', () => { abortNavigation(true) }, { global: true }) }) + it('handles return types of validate', () => { + definePageMeta({ + validate: async () => { + await new Promise(resolve => setTimeout(resolve, 1000)) + // eslint-disable-next-line + if (0) { + return createError({ + statusCode: 404, + statusMessage: 'resource-type-not-found' + }) + } + return true + } + }) + }) }) describe('typed router integration', () => {