diff --git a/packages/core/postgrest-js/src/PostgrestBuilder.ts b/packages/core/postgrest-js/src/PostgrestBuilder.ts index 80b1510f8..d2421ea26 100644 --- a/packages/core/postgrest-js/src/PostgrestBuilder.ts +++ b/packages/core/postgrest-js/src/PostgrestBuilder.ts @@ -154,9 +154,9 @@ export default abstract class PostgrestBuilder< * * @category Database */ - throwOnError(): this & PostgrestBuilder { + throwOnError(): Omit & PostgrestBuilder { this.shouldThrowOnError = true - return this as this & PostgrestBuilder + return this as Omit & PostgrestBuilder } /** diff --git a/packages/core/postgrest-js/test/index.test-d.ts b/packages/core/postgrest-js/test/index.test-d.ts index a3d5748bc..e442a25b0 100644 --- a/packages/core/postgrest-js/test/index.test-d.ts +++ b/packages/core/postgrest-js/test/index.test-d.ts @@ -299,6 +299,20 @@ const postgrestWithOptions = new PostgrestClient(REST_URL) error } +{ + postgrest + .from('messages') + .select('id') + .eq('id', 1) + .single() + .throwOnError() + .then(({ data, error }) => { + expectType>(true) + expectType>(true) + return data + }) +} + // Json Accessor with custom types overrides { const result = await postgrest