Skip to content

chore: Types improvements. #122

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

Merged
merged 3 commits into from
Oct 21, 2020
Merged

chore: Types improvements. #122

merged 3 commits into from
Oct 21, 2020

Conversation

thorwebdev
Copy link
Contributor

r? @soedirgo @kiwicopple (I might need some help with updating the test snapshots)

What kind of change does this PR introduce?

  • Make PostgrestResponse data always an array
  • Introduce PostgrestSingleResponse and make single return PromiseLike<PostgrestSingleResponse<T>>
    • This means single has to be called at the very end of the method chain in a TypeScript context.
  • Make sure PostgrestResponse is correctly assigned as the return type of onfulfilled callback.

Additional context

I've tested this in a TypeScript project:
image

@thorwebdev
Copy link
Contributor Author

image
Ah damn /o\

Copy link
Member

@soedirgo soedirgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @thorwebdev, didn't occur to me to just cast the result of single...

Co-authored-by: Bobbie Soedirgo <[email protected]>
@@ -68,8 +68,8 @@ export default class PostgrestTransformBuilder<T> extends PostgrestBuilder<T> {
* Retrieves only one row from the result. Result must be one row (e.g. using
* `limit`), otherwise this will result in an error.
*/
single(): PostgrestTransformBuilder<T> {
single(): PromiseLike<PostgrestSingleResponse<T>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol wtf

@kiwicopple
Copy link
Member

Nice one Thor, Bobbie! Team work makes the dream work

@kiwicopple kiwicopple merged commit 9f40170 into master Oct 21, 2020
@github-actions
Copy link

🎉 This PR is included in version 0.21.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@soedirgo soedirgo deleted the thor/types-improvements branch June 20, 2021 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants