From 861b0cbf26d5cf6fe64acb01caf5bdd6bd985a05 Mon Sep 17 00:00:00 2001 From: Alex Okrushko Date: Sat, 13 Apr 2019 15:53:28 -0400 Subject: [PATCH] fix(example): handle possible undefined results from Dictionary (#1745) Closes #1735 --- projects/example-app/src/app/books/reducers/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/example-app/src/app/books/reducers/index.ts b/projects/example-app/src/app/books/reducers/index.ts index 73146eab03..fdee5d7ea9 100644 --- a/projects/example-app/src/app/books/reducers/index.ts +++ b/projects/example-app/src/app/books/reducers/index.ts @@ -7,6 +7,7 @@ import * as fromSearch from '@example-app/books/reducers/search.reducer'; import * as fromBooks from '@example-app/books/reducers/books.reducer'; import * as fromCollection from '@example-app/books/reducers/collection.reducer'; import * as fromRoot from '@example-app/reducers'; +import { Book } from '../models/book'; export interface BooksState { search: fromSearch.State; @@ -122,7 +123,9 @@ export const getSearchResults = createSelector( getBookEntities, getSearchBookIds, (books, searchIds) => { - return searchIds.map(id => books[id]); + return searchIds + .map(id => books[id]) + .filter((book): book is Book => book != null); } ); @@ -148,7 +151,9 @@ export const getBookCollection = createSelector( getBookEntities, getCollectionBookIds, (entities, ids) => { - return ids.map(id => entities[id]); + return ids + .map(id => entities[id]) + .filter((book): book is Book => book != null); } );