Open probablykasper opened 1 year ago
When doing a foreign table query, for some reason the type is T | T[] | null.
T | T[] | null
With the following code
const { data, error } = await supabaseClient .from('pages') .select(`*, profiles ( id )`) .eq('name', event.params.page) if (data) { const { profiles, ...page } = data[0] }
I get this type shown when I hover over the profiles variable:
profiles
const profiles: { id: string; } | { id: string; }[] | null
If supabase-js doesn't have enough information to tell how many results the foreign query can give, I'd expect the type to only be T[].
T[]
If supabase-js does know that only 0-1 records can be returned, then I'd expect the type to only be T | null.
0-1
T | null
Bug report
Describe the bug
When doing a foreign table query, for some reason the type is
T | T[] | null
.To Reproduce
With the following code
I get this type shown when I hover over the
profiles
variable:Expected behavior
If supabase-js doesn't have enough information to tell how many results the foreign query can give, I'd expect the type to only be
T[]
.If supabase-js does know that only
0-1
records can be returned, then I'd expect the type to only beT | null
.System information