Skip to content

Commit f75c7ee

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

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ 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(
168+
action: (snapshot: DataSnapshot & { key: string }) => boolean | void
169+
): boolean {
168170
validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
169171
validateCallback('DataSnapshot.forEach', 'action', action, false);
170172
return this._delegate.forEach(expDataSnapshot =>

packages/database-types/index.d.ts

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

packages/database/src/api/Reference_impl.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ 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(
398+
action: (child: DataSnapshot & { key: string }) => boolean | void
399+
): boolean {
398400
if (this._node.isLeafNode()) {
399401
return false;
400402
}

packages/firebase/compat/index.d.ts

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

0 commit comments

Comments
 (0)