Skip to content

Commit 2e8125b

Browse files
committed
Updated typings for database methods
1 parent 14ccbad commit 2e8125b

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

packages/database-types/index.d.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,36 @@ export interface Reference extends Query {
125125
onDisconnect(): OnDisconnect;
126126
parent: Reference | null;
127127
push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
128-
remove(onComplete?: (a: Error | null) => any): Promise<any>;
128+
remove(onComplete?: (a: Error | null) => void): Promise<void>;
129129
root: Reference;
130-
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
130+
set(value: any, onComplete?: (a: Error | null) => void): Promise<void>;
131131
setPriority(
132132
priority: string | number | null,
133-
onComplete: (a: Error | null) => any
134-
): Promise<any>;
133+
onComplete: (a: Error | null) => void
134+
): Promise<void>;
135135
setWithPriority(
136136
newVal: any,
137137
newPriority: string | number | null,
138-
onComplete?: (a: Error | null) => any
139-
): Promise<any>;
138+
onComplete?: (a: Error | null) => void
139+
): Promise<void>;
140140
transaction(
141141
transactionUpdate: (a: any) => any,
142-
onComplete?: (a: Error | null, b: boolean, c: DataSnapshot | null) => any,
142+
onComplete?: (a: Error | null, b: boolean, c: DataSnapshot | null) => void,
143143
applyLocally?: boolean
144-
): Promise<any>;
145-
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
144+
): Promise<TransactionResult>;
145+
update(values: Object, onComplete?: (a: Error | null) => void): Promise<void>;
146146
}
147147

148148
export interface ServerValue {
149149
TIMESTAMP: Object;
150150
increment(delta: number): Object;
151151
}
152152

153+
export interface TransactionResult {
154+
readonly committed: boolean;
155+
readonly snapshot: DataSnapshot;
156+
}
157+
153158
export interface ThenableReference
154159
extends Reference,
155160
Pick<Promise<Reference>, 'then' | 'catch'> {}

packages/firebase/compat/index.d.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7082,7 +7082,7 @@ declare namespace firebase.database {
70827082
* complete.
70837083
* @return Resolves when remove on server is complete.
70847084
*/
7085-
remove(onComplete?: (a: Error | null) => any): Promise<any>;
7085+
remove(onComplete?: (a: Error | null) => void): Promise<void>;
70867086
/**
70877087
* The root `Reference` of the Database.
70887088
*
@@ -7160,7 +7160,7 @@ declare namespace firebase.database {
71607160
* complete.
71617161
* @return Resolves when write to server is complete.
71627162
*/
7163-
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
7163+
set(value: any, onComplete?: (a: Error | null) => void): Promise<void>;
71647164
/**
71657165
* Sets a priority for the data at this Database location.
71667166
*
@@ -7172,8 +7172,8 @@ declare namespace firebase.database {
71727172
*/
71737173
setPriority(
71747174
priority: string | number | null,
7175-
onComplete: (a: Error | null) => any
7176-
): Promise<any>;
7175+
onComplete: (a: Error | null) => void
7176+
): Promise<void>;
71777177
/**
71787178
* Writes data the Database location. Like `set()` but also specifies the
71797179
* priority for that data.
@@ -7187,8 +7187,8 @@ declare namespace firebase.database {
71877187
setWithPriority(
71887188
newVal: any,
71897189
newPriority: string | number | null,
7190-
onComplete?: (a: Error | null) => any
7191-
): Promise<any>;
7190+
onComplete?: (a: Error | null) => void
7191+
): Promise<void>;
71927192
/**
71937193
* Atomically modifies the data at this location.
71947194
*
@@ -7280,9 +7280,9 @@ declare namespace firebase.database {
72807280
a: Error | null,
72817281
b: boolean,
72827282
c: firebase.database.DataSnapshot | null
7283-
) => any,
7283+
) => void,
72847284
applyLocally?: boolean
7285-
): Promise<any>;
7285+
): Promise<TransactionResult>;
72867286
/**
72877287
* Writes multiple values to the Database at once.
72887288
*
@@ -7329,7 +7329,21 @@ declare namespace firebase.database {
73297329
* complete.
73307330
* @return Resolves when update on server is complete.
73317331
*/
7332-
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
7332+
update(
7333+
values: Object,
7334+
onComplete?: (a: Error | null) => void
7335+
): Promise<void>;
7336+
}
7337+
7338+
interface TransactionResult {
7339+
/**
7340+
* Whether the transaction was successfully committed.
7341+
*/
7342+
readonly committed: boolean;
7343+
/**
7344+
* The resulting data snapshot.
7345+
*/
7346+
readonly snapshot: DataSnapshot;
73337347
}
73347348

73357349
interface ThenableReference

0 commit comments

Comments
 (0)