
Description
As we and probably most use postgrest-js through supabase-js, I also opened a bug here. The bug report for postgrest-js: supabase/postgrest-js#561
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
With the latest release v2.45.5 when importing PostgrestError from supabase-js, the PostgrestError class (https://github.com/supabase/postgrest-js/blob/master/src/PostgrestError.ts) is now imported instead of the PostgrestError type (https://github.com/supabase/postgrest-js/blob/master/src/types.ts) which are not compatible:
Type
PostgrestError
is not assignable to typePostgrestError
.
This change was introduced with this pull request: supabase/postgrest-js#555
To reproduce
Write a generic function with a PostgrestError object as a parameter:
import { PostgrestError } from '@supabase/supabase-js'
export function handlePostgrestError(error: PostgrestError) {
// do stuff
}
Then try to use this function with an error object returned by, e.g., a Supabase query:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient<Database>(
import.meta.env.SUPABASE_URL,
import.meta.env.SUPABASE_KEY,
)
function loadData(someId: string) {
const { data, error } = await supabaseAdmin
.from('some_table')
.select('some_column')
.eq('id', someId)
.single()
if (error) {
handlePostgrestError(error)
return
}
...
}
Expected behavior
Type-check is successful
System information
- Version of supabase-js: v2.45.5