Description
Is your feature request related to a problem? Please describe.
I was just wondering why the TypeScript types are currently exported as an interface rather than as a type. I'm trying to create some tooling around Supabase (see here) and I'd like users to be able to use their database types.
However, since it's an interface and not a type, I can't have constraints on the type. For example, supabase-js
has a GenericSchema
type internally and I'd like to be able to create the following:
type GenericDatabase = Record<string, GenericSchema>
function myFunc<Database extends GenericDatabase>() {}
However, since the generated Database
is an interface, it doesn't actually satisfy this constraint. Is there a specific reason this has to be an interface? Having a type would make things much easier for extension authors like myself.
It would also be nice if GenericSchema
, GenericTable
etc. were exported 🙂
I think it could also make typing within the SupabaseClient
easier too, as there is currently loads of (potentially unnecessary) conditional type checking whether the user's Database type is valid.
If changing it to a type wouldn't break things, how open would people be to changing it? Alternatively there could be a flag in the gen types
command that allows you to change which is generated. Currently I'll have to ask my users to manually change it each time they refresh their types, which is a pain...
Describe the solution you'd like
Change the generated Database
to a type
rather than an interface
, or provide a CLI flag that allows it.
Describe alternatives you've considered
I currently provide a way using sed
for my users to change the output when generating their types, but it's not a neat solution at all.