Closed
Description
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
.throwOnError
should return non-nullable type because since in a case of error it will throw instead of returning an error
object with null data
object.
To Reproduce
See below code for example:
const { data, error } = await supabase.from('groups').insert({ name }).select('id').throwOnError().single()
In this example return type is nullabe { data: { id: string } } | null
but it shouldn't because it'll throw on error.
In this case I have to do below to correct typing which doesn't make any sense to do extra if checks even though it's unnecessary:
const { data, error } = await supabase.from('groups').insert({ name }).select('id').throwOnError().single()
if (error) throw error
Expected behavior
If .throwOnError
called return type must be { data: NonNullable<...>, error: null }
or even without error object if possible.
Screenshots

System information
- OS: MacOS
- Version of supabase-js: 2.26.0
- Version of Node.js: 20.3.1
- Version of Typescript: 5.1.3