Generated TypeScript Types - Add type safe to Tables #27458
Unanswered
JediPixels
asked this question in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I Generated the TypeScript Types for the Database by following the instructions at https://supabase.com/docs/guides/api/rest/generating-types and initialized it:
const supabase = createClient<Database>(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY)Then I retrieve the records from the database:
const { data } = await supabase.from(‘contacts’).select(‘*’)I was using interface models like this:
But now I would like to use the new Generated TypeScript Types to assign data to a Vue 3 TypeScript ref()
Before:
After with Generated TypeScript Types:
Is this the correct way of doing this with Generated TypeScript Types? It seems that using
Tables<‘contacts’>and manually typing the contacts name could cause issues if misspelled. Imagine this being used in many, many places in the app.The following is an example of how I am using them:
Feature Request
It would be nicer if we could do something like this instead, this way there would be no misspells:
Tables.Contactsinstead ofTables<'contacts'>Thanks
All reactions