Always running supabase gen types typescript
but annoyed that it cannot (it really can't because it doesn't know) derive your JSON columns?
But you do know that your JSON column will always be a certain structure?
Here's the solution: An easy way to adapt the derived types and having fully typed JSON columns within your Supabase client.
- You generate the types at
supabase.ts
- You
import { Database } from './supabase';
- You instantiate a client with
createClient<Database>
from the previous import
- You generate the types at
supabase.ts
- You copy the file
supabase.extended.ts
to the same directory - You adapt
TableExtensions
to your likings - You
import { Database } from './supabase.extended
- You instantiate a client with
createClient<Database>
from the previous import (of the extended file, not thesupabase.ts
)
That's it.
By supporting me with coffee at https://ko-fi.com/activenode and by following me on your favorite channels: