I have this “types.ts” that i use for using the types generated with Supabase CLI more efficently
import { Database } from './database.types';
export type Tables<T extends keyof Database['public']['Tables']> =
Database['public']['Tables'][T]['Row'];
export type Enums<T extends keyof Database['public']['Enums']> =
Database['public']['Enums'][T];
The problem is that i can’t manage to make this work with a query that needs to have a join…
The code would still work fine, so for example
type EventListItemProps = {
event: Tables<"events">
}
will let me access event.name and also event.table1.name, but the IDE tells me (obviously) that “Property ‘table1’ does not exist on type”
i was thinking that maybe something like
type EventListItemProps = {
event: Tables<"events"> & {
table1: Tables<"table1">;
};
}
would work, but i should do it for every case of SELECT with a join and that would be awful…If is possible i would like to have something more generic, that can adapt to most of the cases.
Thanks for any help, and forgive me for my english!
Andrea Maffioletti Maffio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.