File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ ts_test_library(
99 ),
1010 deps = [
1111 "//modules/entity" ,
12+ "//modules/store" ,
1213 "@npm//rxjs" ,
1314 ],
1415)
@@ -17,6 +18,5 @@ jasmine_node_test(
1718 name = "test" ,
1819 deps = [
1920 ":test_lib" ,
20- "//modules/entity" ,
2121 ],
2222)
Original file line number Diff line number Diff line change 66 AnimalFarm ,
77 TheGreatGatsby ,
88} from './fixtures/book' ;
9+ import { MemoizedSelector , createSelector } from '@ngrx/store' ;
910
1011describe ( 'Entity State Selectors' , ( ) => {
1112 describe ( 'Composed Selectors' , ( ) => {
@@ -89,6 +90,14 @@ describe('Entity State Selectors', () => {
8990 expect ( entities ) . toEqual ( state . entities ) ;
9091 } ) ;
9192
93+ it ( 'should type single entity from Dictionary as entity type or undefined' , ( ) => {
94+ // MemoizedSelector acts like a type checker
95+ const singleEntity : MemoizedSelector <
96+ EntityState < BookModel > ,
97+ BookModel | undefined
98+ > = createSelector ( selectors . selectEntities , enitites => enitites [ 0 ] ) ;
99+ } ) ;
100+
92101 it ( 'should create a selector for selecting the list of models' , ( ) => {
93102 const models = selectors . selectAll ( state ) ;
94103
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ export type IdSelectorNum<T> = (model: T) => number;
99export type IdSelector < T > = IdSelectorStr < T > | IdSelectorNum < T > ;
1010
1111export interface DictionaryNum < T > {
12- [ id : number ] : T ;
12+ [ id : number ] : T | undefined ;
1313}
1414
1515export abstract class Dictionary < T > implements DictionaryNum < T > {
16- [ id : string ] : T ;
16+ [ id : string ] : T | undefined ;
1717}
1818
1919export interface UpdateStr < T > {
You can’t perform that action at this time.
0 commit comments