Skip to content

Commit 9e20717

Browse files
fix: type issue with updateState [backport v19]
Closes #189
1 parent 9b45f1c commit 9e20717

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { signalStore, withMethods } from '@ngrx/signals';
2+
import { setAllEntities, withEntities } from '@ngrx/signals/entities';
3+
import { setLoaded, withCallState } from '../../with-call-state';
4+
import { updateState } from '../update-state';
5+
6+
describe('updateState', () => {
7+
it('should work with multiple updaters', () => {
8+
interface Item {
9+
id: string;
10+
name: string;
11+
}
12+
13+
signalStore(
14+
withEntities<Item>(),
15+
withCallState({ collection: 'items' }),
16+
withMethods((store) => ({
17+
loadItems() {
18+
// This should not cause a type error
19+
updateState(
20+
store,
21+
'Items loaded successfully',
22+
setAllEntities([] as Item[]),
23+
setLoaded('items'),
24+
);
25+
},
26+
})),
27+
);
28+
});
29+
});

libs/ngrx-toolkit/src/lib/devtools/update-state.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
PartialStateUpdater,
44
WritableStateSource,
55
} from '@ngrx/signals';
6-
import { Prettify } from '../shared/prettify';
76
import { currentActionNames } from './internal/current-action-names';
87

98
type PatchFn = typeof originalPatchState extends (
@@ -31,7 +30,7 @@ export function updateState<State extends object>(
3130
stateSource: WritableStateSource<State>,
3231
action: string,
3332
...updaters: Array<
34-
Partial<Prettify<State>> | PartialStateUpdater<Prettify<State>>
33+
Partial<NoInfer<State>> | PartialStateUpdater<NoInfer<State>>
3534
>
3635
): void {
3736
currentActionNames.add(action);

0 commit comments

Comments
 (0)