diff --git a/src/server/templates/typescript.ts b/src/server/templates/typescript.ts index 96a30fe4..e1ec2f11 100644 --- a/src/server/templates/typescript.ts +++ b/src/server/templates/typescript.ts @@ -411,7 +411,13 @@ export interface Database { } }` })} -}` +} + +export type Tables = + Database["public"]["Tables"][T]["Row"]; +export type Enums = + Database["public"]["Enums"][T]; +` output = prettier.format(output, { parser: 'typescript', diff --git a/test/server/typegen.ts b/test/server/typegen.ts index 793f7450..65025db4 100644 --- a/test/server/typegen.ts +++ b/test/server/typegen.ts @@ -363,6 +363,11 @@ test('typegen', async () => { } } } + + export type Tables = + Database["public"]["Tables"][T]["Row"] + export type Enums = + Database["public"]["Enums"][T] " `) }) @@ -747,6 +752,11 @@ test('typegen w/ one-to-one relationships', async () => { } } } + + export type Tables = + Database["public"]["Tables"][T]["Row"] + export type Enums = + Database["public"]["Enums"][T] " `) })