Skip to content
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

database.Reference.push() has no catch but has an Error in it's onComplete handler #433

Closed
DimitarNestorov opened this issue Jan 2, 2019 · 3 comments

Comments

@DimitarNestorov
Copy link

Describe your environment

  • Operating System version: macOS 10.14.2
  • Firebase SDK version: N/A
  • Library version: 6.0.0
  • Firebase Product: database

Describe the problem

firebase-admin/lib/index.d.ts:
image

I don't even know how is this possible, here's what @firebase/database/src/api/Reference.d.ts looks like (Reference has a catch):
image

@hiranya911
Copy link
Contributor

Can you be a bit more specific as to what the problem is? Here's how the JS SDK declares the push() method:

push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;

https://github.com/firebase/firebase-js-sdk/blob/c6357fbaf99e80257816dafb28e748de4a039edf/packages/database-types/index.d.ts#L101

As you can see it is identical to how the push() method is declared in firebase-admin.

@DimitarNestorov
Copy link
Author

I want to use .catch for .push but ThenableReference doesn't have it. Yet the real .push has it. Now I have to use the onComplete handler or use as Promise<Reference>.

@hiranya911
Copy link
Contributor

This is probably because ThenableReference extends from PromiseLike instead of Promise. It's up to the RTDB team to revise/update this API, so please report it at https://github.com/firebase/firebase-js-sdk. If they agree to make the change, we will update the corresponding typings at our end.

In the meantime you can always do the following to register an error callback with push():

      ref.push({foo: 'bar'}, (err) => {
        console.log(err);
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants