Skip to content

Commit

Permalink
Fix a typing error in database-types (#3968)
Browse files Browse the repository at this point in the history
* push should return a ThenableReference

* make thenable only implement then & catch

* Create tame-knives-change.md

* Update .changeset/tame-knives-change.md

Co-authored-by: Sebastian Schmidt <[email protected]>

Co-authored-by: Sebastian Schmidt <[email protected]>
  • Loading branch information
Feiyang1 and schmidt-sebastian authored Oct 20, 2020
1 parent 9719635 commit 602ec18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changeset/tame-knives-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@firebase/database-types": patch
"@firebase/database": patch
"firebase": patch
---

Updated the type definition for `ThenableReference` to only implement `then` and `catch`, which matches the implementation.
6 changes: 4 additions & 2 deletions packages/database-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface Reference extends Query {
key: string | null;
onDisconnect(): OnDisconnect;
parent: Reference | null;
push(value?: any, onComplete?: (a: Error | null) => any): Reference;
push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
remove(onComplete?: (a: Error | null) => any): Promise<any>;
root: Reference;
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
Expand All @@ -134,7 +134,9 @@ export interface ServerValue {
increment(delta: number): Object;
}

export interface ThenableReference extends Reference, Promise<Reference> {}
export interface ThenableReference
extends Reference,
Pick<Promise<Reference>, 'then' | 'catch'> {}

export function enableLogging(
logger?: boolean | ((a: string) => any),
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6902,7 +6902,7 @@ declare namespace firebase.database {

interface ThenableReference
extends firebase.database.Reference,
Promise<Reference> {}
Pick<Promise<Reference>, 'then' | 'catch'> {}

/**
* Logs debugging information to the console.
Expand Down

0 comments on commit 602ec18

Please sign in to comment.