postgrest-js
postgrest-js copied to clipboard
.throwOnError() only adjusts types correctly if await is used and is still incorrect if you use `then`
Bug report
- [x] 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