Skip to content
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

.throwOnError() only adjusts types correctly if await is used and is still incorrect if you use then #601

Open
1 of 2 tasks
MrPiao opened this issue Feb 9, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@MrPiao
Copy link

MrPiao commented Feb 9, 2025

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

awaiting a query with .throwOnError() correctly eliminates null from the typing. However, if you don't await it and use .then(...) instead, then null is not eliminated from the typing.

To Reproduce

supabase.from('users').select('id').eq('id', id).single().throwOnError().then(({ data }) => { ... });

Expected behavior

Type of data should be { id: string }

Actual behavior

Type of data is { id: string } | null

@MrPiao MrPiao added the bug Something isn't working label Feb 9, 2025
@MrPiao
Copy link
Author

MrPiao commented Feb 9, 2025

My guess is that #563 did not cover this use case and it was not automatically fixed because it uses non-standard Promise objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant