File tree Expand file tree Collapse file tree 5 files changed +14
-9
lines changed Expand file tree Collapse file tree 5 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -203,8 +203,15 @@ export default defineNuxtModule<ModuleOptions>({
203203 addTemplate ( {
204204 filename : 'types/supabase-database.d.ts' ,
205205 getContents : async ( ) => {
206- if ( ! ! options . types && fs . existsSync ( await resolvePath ( options . types ) ) ) {
207- return `export * from '${ await resolvePath ( options . types ) } '`
206+ if ( options . types ) {
207+ // resolvePath is used to minify user input error.
208+ const path = await resolvePath ( options . types )
209+ const basePath = await resolvePath ( '~~' ) // ~~ should be the base path in a nuxt project.
210+
211+ if ( fs . existsSync ( path ) ) {
212+ // we are replacing the basePath with ../.. to move back to the root (~~) directory.
213+ return `export * from '${ path . replace ( basePath , '../..' ) } '`
214+ }
208215 }
209216
210217 return `export type Database = unknown`
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ import type { SupabaseClient } from '@supabase/supabase-js'
22import { useNuxtApp } from '#imports'
33import type { Database } from '#build/types/supabase-database'
44
5- export const useSupabaseClient = < T = Database > ( ) => {
5+ export const useSupabaseClient : < T = Database > ( ) => SupabaseClient < T > = < T = Database > ( ) => {
66 return useNuxtApp ( ) . $supabase ?. client as SupabaseClient < T >
77}
Original file line number Diff line number Diff line change 11import type { Session } from '@supabase/supabase-js'
2- import { useState } from '#imports'
2+ import { useState , type Ref } from '#imports'
33
44/**
55 * Reactive `Session` state from Supabase. This is initialized in both client and server plugin
66 * and, on the client, also updated through `onAuthStateChange` events.
77 */
8- export const useSupabaseSession = ( ) => useState < Session | null > ( 'supabase_session' , ( ) => null )
8+ export const useSupabaseSession = ( ) : Ref < Session > => useState < Session | null > ( 'supabase_session' , ( ) => null )
Original file line number Diff line number Diff line change 11import type { User } from '@supabase/supabase-js'
2- import { useState } from '#imports'
2+ import { useState , type Ref } from '#imports'
33
44/**
55 * Reactive `User` state from Supabase. This is initialized in both client and server plugin
66 * and, on the client, also updated through `onAuthStateChange` events.
77 */
8- export const useSupabaseUser = ( ) => useState < User | null > ( 'supabase_user' , ( ) => null )
8+ export const useSupabaseUser = ( ) : Ref < User > => useState < User | null > ( 'supabase_user' , ( ) => null )
Original file line number Diff line number Diff line change 22 "extends" : " ./.nuxt/tsconfig.json" ,
33 "compilerOptions" : {
44 "strictNullChecks" : false ,
5- "baseUrl" : " src"
65 }
76}
8-
You can’t perform that action at this time.
0 commit comments