diff --git a/src/database/api/Query.ts b/src/database/api/Query.ts index aec0d6770e0..4b9e66fec3b 100644 --- a/src/database/api/Query.ts +++ b/src/database/api/Query.ts @@ -22,6 +22,10 @@ import { DataSnapshot } from './DataSnapshot'; let __referenceConstructor: new(repo: Repo, path: Path) => Query; +export interface SnapshotCallback { + (a: DataSnapshot, b?: string): any +} + /** * A Query represents a filter to be applied to a firebase location. This object purely represents the * query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js. @@ -143,8 +147,8 @@ export class Query { * @param {Object=} context * @return {!function(DataSnapshot, string=)} */ - on(eventType: string, callback: (a: DataSnapshot, b?: string) => any, - cancelCallbackOrContext?: ((a: Error) => any) | Object, context?: Object): (a: DataSnapshot, b?: string) => any { + on(eventType: string, callback: SnapshotCallback, + cancelCallbackOrContext?: ((a: Error) => any) | Object, context?: Object): SnapshotCallback { validateArgCount('Query.on', 2, 4, arguments.length); validateEventType('Query.on', 1, eventType, false); validateCallback('Query.on', 2, callback, false); @@ -177,7 +181,7 @@ export class Query { * @param {?function(Error)} cancelCallback * @param {?Object} context */ - onChildEvent(callbacks: { [k: string]: (a: DataSnapshot, b: string | null) => any }, + onChildEvent(callbacks: { [k: string]: SnapshotCallback }, cancelCallback: ((a: Error) => any) | null, context: Object | null) { const container = new ChildEventRegistration(callbacks, cancelCallback, context); this.repo.addEventCallbackForQuery(this, container); @@ -217,7 +221,7 @@ export class Query { * @param context * @return {!firebase.Promise} */ - once(eventType: string, userCallback: (a: DataSnapshot, b?: string) => any, + once(eventType: string, userCallback: SnapshotCallback, cancelOrContext?, context?: Object) { validateArgCount('Query.once', 1, 4, arguments.length); validateEventType('Query.once', 1, eventType, false); @@ -376,7 +380,7 @@ export class Query { } // Calling with no params tells us to start at the beginning. - if (value == null) { + if (value === undefined) { value = null; name = null; } diff --git a/tests/config/project.json b/tests/config/project.json new file mode 100644 index 00000000000..10dc41ebbbc --- /dev/null +++ b/tests/config/project.json @@ -0,0 +1 @@ +{"apiKey":"AIzaSyBNHCyZ-bpv-WA-HpXTmigJm2aq3z1kaH8","authDomain":"jscore-sandbox-141b5.firebaseapp.com","databaseURL":"https://jscore-sandbox-141b5.firebaseio.com","projectId":"jscore-sandbox-141b5","storageBucket":"jscore-sandbox-141b5.appspot.com","messagingSenderId":"280127633210"}