supabase-js
supabase-js copied to clipboard
`@supabase/supabase-js` TypeScript types - on join query
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Types generated for TypeScript, based on the query content are not correct:
Query
const result = await dbServerClient
.from('table_1')
.select(
'processed, created_at, table_2:table_2_id (name, table_3:table_3_id (name, image))',
)
.eq('id', id)
Provided type
PostgrestSingleResponse<{
processed: any;
created_at: any;
table_2: {
name: any;
table_3: {
name: any;
image: any;
}[];
}[];
}[]>
Type in reality
PostgrestSingleResponse<{
processed: string;
created_at: string;
table_2: {
name: string;
table_3: {
name: string;
image: string;
};
};
}[]>
Additional context
In theory difference is small, but it makes big types issues, since casting is required to make it work correctly.
A fix for this would be greatly appreciated. Without this I'm still writing out types manually.
@sethtjf I suggest you to use zod for validation
Ah! I spent quite some time looking for a solution to this in the docs and elsewhere on the internet. I guess overriding the type is the only way for now.