Skip to content

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

@MrPiao

Description

@MrPiao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas workaroundIssue has a valid workaround.postgrest-jsRelated to the postgrest-js library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions