@@ -243,6 +243,56 @@ describe('withEntityResources', () => {
243243 expect ( store . entities ( ) ) . toEqual ( [ ] ) ;
244244 } ) ;
245245
246+ it ( 'does not support setAllEntities/addEntity/removeEntity for named which are of type Resource' , async ( ) => {
247+ const Store = signalStore (
248+ { providedIn : 'root' , protectedState : false } ,
249+ withEntityResources ( ( ) => ( {
250+ todos : withPreviousValue (
251+ resource ( {
252+ loader : ( ) => Promise . resolve ( [ ] as Todo [ ] ) ,
253+ defaultValue : [ ] ,
254+ } ) ,
255+ ) ,
256+ } ) ) ,
257+ ) ;
258+
259+ const store = TestBed . inject ( Store ) ;
260+
261+ await wait ( ) ;
262+
263+ const invalidSetAll = ( ) =>
264+ patchState (
265+ store ,
266+ // @ts -expect-error Resources which are of type Resource should not support entity updaters
267+ setAllEntities (
268+ [
269+ { id : 1 , title : 'A' , completed : false } ,
270+ { id : 2 , title : 'B' , completed : true } ,
271+ ] as Todo [ ] ,
272+ { collection : 'todos' } ,
273+ ) ,
274+ ) ;
275+
276+ const invalidAdd = ( ) =>
277+ patchState (
278+ store ,
279+ // @ts -expect-error Resources which are of type Resource should not support entity updaters
280+ addEntity ( { id : 3 , title : 'C' , completed : false } as Todo , {
281+ collection : 'todos' ,
282+ } ) ,
283+ ) ;
284+
285+ const invalidRemove = ( ) =>
286+ // @ts -expect-error Resources which are of type Resource should not support entity updaters
287+ patchState ( store , removeEntity ( 2 , { collection : 'todos' } ) ) ;
288+
289+ expect ( invalidSetAll ) . toBeDefined ( ) ;
290+ expect ( invalidAdd ) . toBeDefined ( ) ;
291+ expect ( invalidRemove ) . toBeDefined ( ) ;
292+ expect ( store . todosIds ( ) ) . toEqual ( [ ] ) ;
293+ expect ( store . todosEntities ( ) ) . toEqual ( [ ] ) ;
294+ } ) ;
295+
246296 it ( 'supports setAllEntities/addEntity/removeEntity for named' , async ( ) => {
247297 const Store = signalStore (
248298 { providedIn : 'root' , protectedState : false } ,
0 commit comments