Skip to content

Commit d8db05d

Browse files
authored
Revert "Revert "Updated type of action parameter for DataSnapshot#forEach" (#6536)"
This reverts commit 9f1e3c6.
1 parent 9f1e3c6 commit d8db05d

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

.changeset/orange-doors-swim.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

common/api-review/database.api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export class DataSnapshot {
3333
child(path: string): DataSnapshot;
3434
exists(): boolean;
3535
exportVal(): any;
36-
forEach(action: (child: DataSnapshot) => boolean | void): boolean;
36+
forEach(action: (child: DataSnapshot & {
37+
key: string;
38+
}) => boolean | void): boolean;
3739
hasChild(path: string): boolean;
3840
hasChildren(): boolean;
3941
get key(): string | null;

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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ export class DataSnapshot {
393393
* @returns true if enumeration was canceled due to your callback returning
394394
* true.
395395
*/
396-
forEach(action: (child: DataSnapshot) => boolean | void): boolean {
396+
forEach(
397+
action: (child: DataSnapshot & { key: string }) => boolean | void
398+
): boolean {
397399
if (this._node.isLeafNode()) {
398400
return false;
399401
}

packages/firebase/compat/index.d.ts

Lines changed: 3 additions & 1 deletion
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)