diff --git a/CHANGELOG.md b/CHANGELOG.md index e97214632..0f5f3d22f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,2 @@ - Fixes access on deeply nested, nonexistent property. (#1432) +- Add IteratedDataSnapshot interface to match with firebase admin v12 (#1517). diff --git a/src/common/providers/database.ts b/src/common/providers/database.ts index 1200cc73a..d73bb5503 100644 --- a/src/common/providers/database.ts +++ b/src/common/providers/database.ts @@ -25,6 +25,14 @@ import * as database from "firebase-admin/database"; import { firebaseConfig } from "../../common/config"; import { joinPath, pathParts } from "../../common/utilities/path"; +/** + * Pulled from @firebase/database-types, make sure the interface is updated on dependencies upgrades. + * Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined. + */ +interface IteratedDataSnapshot extends DataSnapshot { + key: string; // key of the location of this snapshot. +} + /** * Interface representing a Firebase Realtime database data snapshot. */ @@ -207,7 +215,7 @@ export class DataSnapshot implements database.DataSnapshot { * @return `true` if enumeration was canceled due to your callback * returning `true`. */ - forEach(action: (a: DataSnapshot) => boolean | void): boolean { + forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean { const val = this.val() || {}; if (typeof val === "object") { return Object.keys(val).some((key) => action(this.child(key)) === true);