© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
meenie

Typescript return type for Functions

I really appreciate the
supabase gen types typescript
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;
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
setof shifts
which is a table in my schema. The generated type for this is

    Functions: {
      shifts_by_week: {
        Args: { date: string }
        Returns: unknown
      }
    }
    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.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,729Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RPC call return type in TypeScript not nullable
SupabaseSSupabase / help-and-questions
2w ago
Supabase RPC functions return type shows a 2D array?
SupabaseSSupabase / help-and-questions
4y ago
Best TypeScript DX for Supabase Edge Functions
SupabaseSSupabase / help-and-questions
13mo ago
Recommended pattern for Return Types on RPC functions
SupabaseSSupabase / help-and-questions
7mo ago