File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
libs/ngrx-toolkit/src/lib Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,22 @@ describe('withDataService', () => {
383
383
} ) ;
384
384
} ) ) ;
385
385
386
+ it ( 'should ensure that collection name is provided in callState ' , ( ) => {
387
+ // @ts -expect-error should not allow `withCallState` without collection name if `withDataService` has it
388
+ signalStore (
389
+ withCallState ( ) ,
390
+ withEntities ( {
391
+ entity : type < Flight > ( ) ,
392
+ collection : 'flight' ,
393
+ } ) ,
394
+ withDataService ( {
395
+ dataServiceType : MockFlightService ,
396
+ filter : { from : 'Paris' , to : 'New York' } ,
397
+ collection : 'flight' ,
398
+ } )
399
+ ) ;
400
+ } ) ;
401
+
386
402
// TODO 3A: setting error state (without named collection)
387
403
// TODO 3B: setting error state (with named collection)
388
404
} ) ;
Original file line number Diff line number Diff line change @@ -11,19 +11,21 @@ import {
11
11
} from '@ngrx/signals' ;
12
12
import {
13
13
CallState ,
14
+ NamedCallStateSlice ,
14
15
getCallStateKeys ,
15
16
setError ,
16
17
setLoaded ,
17
18
setLoading ,
18
19
} from './with-call-state' ;
19
20
import {
21
+ NamedEntityState ,
20
22
setAllEntities ,
21
23
EntityId ,
22
24
addEntity ,
23
25
updateEntity ,
24
26
removeEntity ,
25
27
} from '@ngrx/signals/entities' ;
26
- import { EntityState , NamedEntityComputed } from './shared/signal-store-models' ;
28
+ import { EntityState } from './shared/signal-store-models' ;
27
29
28
30
export type Filter = Record < string , unknown > ;
29
31
export type Entity = { id : EntityId } ;
@@ -201,10 +203,9 @@ export function withDataService<
201
203
filter : F ;
202
204
collection : Collection ;
203
205
} ) : SignalStoreFeature <
204
- // These alternatives break type inference:
205
- // state: { callState: CallState } & NamedEntityState<E, Collection>,
206
- // state: NamedEntityState<E, Collection>,
207
- EmptyFeatureResult & { props : NamedEntityComputed < E , Collection > } ,
206
+ EmptyFeatureResult & {
207
+ state : NamedCallStateSlice < Collection > & NamedEntityState < E , Collection > ;
208
+ } ,
208
209
{
209
210
state : NamedDataServiceState < E , F , Collection > ;
210
211
props : NamedDataServiceComputed < E , Collection > ;
You can’t perform that action at this time.
0 commit comments