TS types incorrect for join tables

I have the following query:
const { data, error } = await supabaseClient
    .from('costs')
    .select('id, title, unit:unit_type_id(name), created_at, updated_at, price_per_unit')
    .eq('category_id', categoryId)


Which results in the following type:
const data:
    | ({ id: string } & { title: string } & {
            unit: { name: unknown } | { name: unknown }[] | null
      } & { created_at: string } & { updated_at: string } & { price_per_unit: unknown })[]
    | null


As you can see, the unit join has incorrect property type of unknown, according to Supabase generated types, it should be string | null How can this be fixed?

On another, note, unit shouldn't be able to be an array. Supabase apparently doesn't recognize the join table at all, and that might be the root of the issue
Was this page helpful?