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(
9
9
),
10
10
deps = [
11
11
"//modules/entity" ,
12
+ "//modules/store" ,
12
13
"@npm//rxjs" ,
13
14
],
14
15
)
@@ -17,6 +18,5 @@ jasmine_node_test(
17
18
name = "test" ,
18
19
deps = [
19
20
":test_lib" ,
20
- "//modules/entity" ,
21
21
],
22
22
)
Original file line number Diff line number Diff line change 6
6
AnimalFarm ,
7
7
TheGreatGatsby ,
8
8
} from './fixtures/book' ;
9
+ import { MemoizedSelector , createSelector } from '@ngrx/store' ;
9
10
10
11
describe ( 'Entity State Selectors' , ( ) => {
11
12
describe ( 'Composed Selectors' , ( ) => {
@@ -89,6 +90,14 @@ describe('Entity State Selectors', () => {
89
90
expect ( entities ) . toEqual ( state . entities ) ;
90
91
} ) ;
91
92
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
+
92
101
it ( 'should create a selector for selecting the list of models' , ( ) => {
93
102
const models = selectors . selectAll ( state ) ;
94
103
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ export type IdSelectorNum<T> = (model: T) => number;
9
9
export type IdSelector < T > = IdSelectorStr < T > | IdSelectorNum < T > ;
10
10
11
11
export interface DictionaryNum < T > {
12
- [ id : number ] : T ;
12
+ [ id : number ] : T | undefined ;
13
13
}
14
14
15
15
export abstract class Dictionary < T > implements DictionaryNum < T > {
16
- [ id : string ] : T ;
16
+ [ id : string ] : T | undefined ;
17
17
}
18
18
19
19
export interface UpdateStr < T > {
You can’t perform that action at this time.
0 commit comments