Skip to content

Commit 1913f64

Browse files
committed
Updated type of action parameter for DataSnapshot#forEach
1 parent e673dc8 commit 1913f64

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/database-compat/src/api/Reference.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class DataSnapshot implements Compat<ModularDataSnapshot> {
164164
* @returns True if forEach was canceled by action returning true for
165165
* one of the child nodes.
166166
*/
167-
forEach(action: (snapshot: DataSnapshot) => boolean | void): boolean {
167+
forEach(action: (snapshot: DataSnapshot & { key: string }) => boolean | void): boolean {
168168
validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
169169
validateCallback('DataSnapshot.forEach', 'action', action, false);
170170
return this._delegate.forEach(expDataSnapshot =>

packages/database-types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface DataSnapshot {
2222
child(path: string): DataSnapshot;
2323
exists(): boolean;
2424
exportVal(): any;
25-
forEach(action: (a: DataSnapshot) => boolean | void): boolean;
25+
forEach(action: (a: DataSnapshot & { key: string }) => boolean | void): boolean;
2626
getPriority(): string | number | null;
2727
hasChild(path: string): boolean;
2828
hasChildren(): boolean;

packages/database/src/api/Reference_impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export class DataSnapshot {
394394
* @returns true if enumeration was canceled due to your callback returning
395395
* true.
396396
*/
397-
forEach(action: (child: DataSnapshot) => boolean | void): boolean {
397+
forEach(action: (child: DataSnapshot & { key: string }) => boolean | void): boolean {
398398
if (this._node.isLeafNode()) {
399399
return false;
400400
}

packages/firebase/compat/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5819,7 +5819,7 @@ declare namespace firebase.database {
58195819
* returning true.
58205820
*/
58215821
forEach(
5822-
action: (a: firebase.database.DataSnapshot) => boolean | void
5822+
action: (a: firebase.database.DataSnapshot & { key: string }) => boolean | void
58235823
): boolean;
58245824
/**
58255825
* Gets the priority value of the data in this `DataSnapshot`.

0 commit comments

Comments
 (0)