From 09bff844d29cfb788cb334860202e2e14a5da2a9 Mon Sep 17 00:00:00 2001 From: Thimo Sietsma Date: Fri, 30 Aug 2024 12:27:22 +0200 Subject: [PATCH] fix(types): add explicit type annotations for plugins (#408) --- src/runtime/plugins/auth-redirect.ts | 5 +++-- src/runtime/plugins/supabase.client.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/runtime/plugins/auth-redirect.ts b/src/runtime/plugins/auth-redirect.ts index 9c8c2451..3ef7965e 100644 --- a/src/runtime/plugins/auth-redirect.ts +++ b/src/runtime/plugins/auth-redirect.ts @@ -1,3 +1,4 @@ +import type { Plugin } from '#app' import type { Ref } from '#imports' import { defineNuxtPlugin, addRouteMiddleware, defineNuxtRouteMiddleware, useCookie, useRuntimeConfig, navigateTo, useSupabaseSession } from '#imports' import type { RouteLocationNormalized } from '#vue-router' @@ -24,7 +25,7 @@ export default defineNuxtPlugin({ } // Do not redirect on login route, callback route and excluded routes - const isExcluded = [...exclude, login, callback]?.some((path) => { + const isExcluded = [...exclude ?? [], login, callback]?.some((path) => { const regex = new RegExp(`^${path.replace(/\*/g, '.*')}$`) return regex.test(to.path) }) @@ -42,4 +43,4 @@ export default defineNuxtPlugin({ { global: true }, ) }, -}) +}) as Plugin diff --git a/src/runtime/plugins/supabase.client.ts b/src/runtime/plugins/supabase.client.ts index 654aa462..3d18422b 100644 --- a/src/runtime/plugins/supabase.client.ts +++ b/src/runtime/plugins/supabase.client.ts @@ -1,6 +1,7 @@ import { createBrowserClient } from '@supabase/ssr' -import type { Session } from '@supabase/supabase-js' +import type { Session, SupabaseClient } from '@supabase/supabase-js' import { fetchWithRetry } from '../utils/fetch-retry' +import type { Plugin } from '#app' import { defineNuxtPlugin, useRuntimeConfig, useSupabaseSession, useSupabaseUser } from '#imports' export default defineNuxtPlugin({ @@ -43,4 +44,4 @@ export default defineNuxtPlugin({ }, } }, -}) +}) as Plugin<{ client: SupabaseClient }>