You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From my understaning of supabase/supabase-js#92.throwOnError() should work as if I were typing something like:
const{data: queryResult,error: queryError}=awaitsupabase.from("cohorts").select("id").single();if(queryError){throwqueryError;}constthisHasTypeId=queryResult;// This is of type { id: number } NOT NULL!!
In the above case thisHasTypeId is of type {id:number}, but if I try to use .throwOnError():
const{data: queryResult,error: queryError}=awaitsupabase.from("cohorts").select("id").single().throwOnError();constthisHasTypeNullToo=queryResult;// This is of type { id: number } | null, WHY NULL??
But here thisHasTypeNullToo has null too! so I would have to do type check as well like this:
const{data: queryResult,error: queryError}=awaitsupabase.from("cohorts").select("id").single().throwOnError();constthisHasTypeNullToo=queryResult;// This is of type { id: number } | null, WHY NULL??if(queryError){throwqueryError;}constthisDoesNotHaveTypeNull=queryResult;// This is of type { id: number } NOT NULL!!
Expected behavior
It would be nice if the returned data didn't include the null type when using .throwOnError().
The text was updated successfully, but these errors were encountered:
When using throwOnError(), the response type is now more strictly typed:
- Data is guaranteed to be non-null
- Error field is removed from response type
- Response type is controlled by generic ThrowOnError boolean parameter
Fixes#563
Bug report
Describe the bug
From my understaning of supabase/supabase-js#92
.throwOnError()
should work as if I were typing something like:In the above case
thisHasTypeId
is of type{id:number}
, but if I try to use.throwOnError()
:But here
thisHasTypeNullToo
has null too! so I would have to do type check as well like this:Expected behavior
It would be nice if the returned
data
didn't include thenull
type when using .throwOnError().The text was updated successfully, but these errors were encountered: