Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/postgrest-js/src/PostgrestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ export default abstract class PostgrestBuilder<
*
* @category Database
*/
throwOnError(): this & PostgrestBuilder<ClientOptions, Result, true> {
throwOnError(): Omit<this, 'then'> & PostgrestBuilder<ClientOptions, Result, true> {
this.shouldThrowOnError = true
return this as this & PostgrestBuilder<ClientOptions, Result, true>
return this as Omit<this, 'then'> & PostgrestBuilder<ClientOptions, Result, true>
}

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/core/postgrest-js/test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ const postgrestWithOptions = new PostgrestClient<DatabaseWithOptions>(REST_URL)
error
}

{
postgrest
.from('messages')
.select('id')
.eq('id', 1)
.single()
.throwOnError()
.then(({ data, error }) => {
expectType<TypeEqual<typeof data, { id: number }>>(true)
expectType<TypeEqual<typeof error, null>>(true)
return data
})
}

// Json Accessor with custom types overrides
{
const result = await postgrest
Expand Down
Loading