Closed bastiaanv closed 1 year ago
Using the new supabase-js, the from function always returns the any type, while I have the Database interface given during initialisation.
from
any
Database
Database.ts
export type Json = | string | number | boolean | null | { [key: string]: Json } | Json[] export interface Database { public: { Tables: { themes: { Row: { id: string name: string color: string image: string } Insert: { id?: string name: string color: string image: string } Update: { id?: string name?: string color?: string image?: string } } }, Views: { [_ in never]: never } Functions: { [_ in never]: never } Enums: { [_ in never]: never } } }
function.ts
export function supabaseClient() { return createClient<Database>(environment.supabase.url, environment.supabase.key, { auth: { autoRefreshToken: true, persistSession: true, }, }); } supabase.from('themes').select('name,colors(*),images(*)').order('id').limit(1).single()
Return message on from:
(method) SupabaseClient<Database, "public", { Tables: { themes: { Row: { id: string; name: string; color: string; image: string; }; Insert: { id?: string | undefined; name: string; color: string; image: string; }; Update: { ...; }; }; }; Views: {}; Functions: {}; Enums: {}; }>.from<"themes", { Row: { id: string; name: string; color: string; image: string; }; Insert: { id?: string | undefined; name: string; color: string; image: string; }; Update: { id?: string | undefined; name?: string | undefined; color?: string | undefined; image?: string | undefined; }; }>(relation: "themes"): any (+2 overloads)
I would expect from to return PostgrestQueryBuilder<{ id: string; name: string; color: string; image: string; }> (or something like that) to continue type safety
PostgrestQueryBuilder<{ id: string; name: string; color: string; image: string; }>
Can you try updating @supabase/supabase-js? This might be related to https://github.com/supabase/supabase-js/issues/602 which we recently fixed
@supabase/supabase-js
It is. Thank you!
Bug report
Using the new supabase-js, the
from
function always returns theany
type, while I have theDatabase
interface given during initialisation.To Reproduce
Database.ts
function.ts
Return message on
from
:Expected behavior
I would expect
from
to returnPostgrestQueryBuilder<{ id: string; name: string; color: string; image: string; }>
(or something like that) to continue type safetySystem information