Typescript return type for Functions

I really appreciate the supabase gen types typescript utility in the CLI tool. One thing I can't get to work is when I define Postgres Functions, it won't determine the return type based on the the function. For example, given this function
create or replace function shifts_by_week(date timestamp default null)
returns setof shifts
as $$
  select * from shifts where date_trunc('week', coalesce($1, current_date) + interval '1 day') - interval '1 day' = date_trunc('week', shifts.date + interval '1 day') - interval '1 day';
$$ language sql;


Where I'm specifying the return is setof shifts which is a table in my schema. The generated type for this is

    Functions: {
      shifts_by_week: {
        Args: { date: string }
        Returns: unknown
      }
    }


I can manually update the file, sure, but it is auto-generated, so I'd rather not. And yes, I could also build a bash script that will generate the types and then mutate them at the end, but I'd rather not.
Was this page helpful?