-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve return types for throwOnError
#364
base: master
Are you sure you want to change the base?
Improve return types for throwOnError
#364
Conversation
i'm still figuring out how to type it correctly. |
@Cryrivers Is there anything I can do to help get this over the line? I would also like to see this fix. Your last message says you're still figuring out the types. What is left to figure out to make the result unwrapping work after |
right now the blocker is the TypeScript error: |
I don't know much, but could this help at all with the types? It claims to be super fast, recursive, and 1:1 with TypeScript |
What kind of change does this PR introduce?
This PR improves return types for
throwOnError
, which excludesnull
for failure responses in the return type. asthrowOnError
raises exceptions instead of providing a failure response.What is the current behavior?
Currently
throwOnError
still types the return data asData | null
, whereas thenull
(failure response) case is impossible to happen.What is the new behavior?
throwOnError
just types the return data asData
(null
is still kept if the data is nullable), if error happens, it throws an exception.Additional context
This PR addresses supabase/supabase-js#554
TypeScript issue
TypeScript (4.8, 4.9) complains the circular references, however the types can be correctly inferred in Visual Studio Code.