How to type any type in subscription on callback
How do you guys type these payloads? I've cooked something up but I really feel like this should be properly typed.
I'm most likely doing something wrong, but no idea what.

7 Replies
@whaley Use a custom TypeScript interface for the payload, like payload: SupabaseInsert <'system_queue'>, to ensure proper typing.
I assume you've already generated types using supabase cli. If you haven't follow this guide https://supabase.com/docs/guides/api/rest/generating-types.
After this, set type for payload like this
hmm, unfortunately that's not working for me. i have generated the types. however i was able to do this using my drizzle schemas instead:
However I think I'd like to stay in supabase world for this file rather than dipping into the drizzle types. But maybe it's not so bad..

oh ik why actually, mb, i have multiple schemas in this db, and i need to dip into that first, but i'm not sure if that's possible with supabase types
tables seems to only pull in the public schema type info
snippet from supabase type def.. i'll have to stick with drizzle schemas for now -- it might actually be better because i won't have to re-generate types

You can pass in a --schema flag when generating types https://supabase.com/docs/reference/cli/supabase-gen-types