Skip to content

Commit 263cd24

Browse files
committed
Finish fixing strictNullCheck errors
1 parent e9d9a93 commit 263cd24

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

packages/rxfire/database/list/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ export function list(
4242
query: database.Query,
4343
events?: ListenEvent[]
4444
): Observable<QueryChange[]> {
45-
events = validateEventsArray(events);
45+
const eventsToList = validateEventsArray(events);
4646
return fromOnce(query).pipe(
4747
switchMap(change => {
4848
const childEvent$ = [of(change)];
49-
events.forEach(event => childEvent$.push(fromRef(query, event)));
49+
eventsToList.forEach(event => childEvent$.push(fromRef(query, event)));
5050
return merge(...childEvent$).pipe(scan(buildView, []));
5151
}),
5252
distinctUntilChanged()
@@ -94,11 +94,11 @@ function buildView(current: QueryChange[], change: QueryChange) {
9494
const { snapshot, prevKey, event } = change;
9595
const { key } = snapshot;
9696
const currentKeyPosition = positionFor(current, key);
97-
const afterPreviousKeyPosition = positionAfter(current, prevKey);
97+
const afterPreviousKeyPosition = positionAfter(current, prevKey || undefined);
9898
switch (event) {
9999
case ListenEvent.value:
100100
if (change.snapshot && change.snapshot.exists()) {
101-
let prevKey = null;
101+
let prevKey: string | null = null;
102102
change.snapshot.forEach(snapshot => {
103103
const action: QueryChange = {
104104
snapshot,

packages/rxfire/database/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ export function isNil(obj: any): boolean {
2626
* that is populated with all the Realtime Database child events.
2727
* @param events
2828
*/
29-
export function validateEventsArray(events?: ListenEvent[]) {
29+
export function validateEventsArray(events?: ListenEvent[]): ListenEvent[] {
30+
let validatedEvents: ListenEvent[] = [];
3031
if (isNil(events) || events!.length === 0) {
31-
events = [
32+
validatedEvents = [
3233
ListenEvent.added,
3334
ListenEvent.removed,
3435
ListenEvent.changed,
3536
ListenEvent.moved
3637
];
3738
}
38-
return events;
39+
return validatedEvents;
3940
}

packages/rxfire/firestore/collection/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const filterEvents = (events?: firestore.DocumentChangeType[]) =>
3737
let hasChange = false;
3838
for (let i = 0; i < changes.length; i++) {
3939
const change = changes[i];
40-
if (events.indexOf(change.type) >= 0) {
40+
if (events && events.indexOf(change.type) >= 0) {
4141
hasChange = true;
4242
break;
4343
}

packages/rxfire/firestore/document/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function docData<T>(
3636
}
3737

3838
export function snapToData(
39-
snapshot: firestore.QueryDocumentSnapshot,
39+
snapshot: firestore.DocumentSnapshot,
4040
idField?: string
4141
) {
4242
return {

packages/testing/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export type AppOptions = {
9393
/** Construct an App authenticated with options.auth. */
9494
export function initializeTestApp(options: AppOptions): firebase.app.App {
9595
return initializeApp(
96-
options.auth ? createUnsecuredJwt(options.auth) : null,
96+
options.auth ? createUnsecuredJwt(options.auth) : undefined,
9797
options.databaseName,
9898
options.projectId
9999
);

0 commit comments

Comments
 (0)