Action payload types are resolved to 'never' inside reducer
Closed this issue · 3 comments
giniedp commented
I was trying out the library and am hitting a type resolution error on the following example
https://stackblitz.com/edit/stackblitz-starters-unmh93?file=src%2Fapp.store.ts
import { payload, withRedux } from '@angular-architects/ngrx-toolkit';
import { patchState, signalStore, withState } from '@ngrx/signals';
export interface Flight {
id: string;
}
export const FlightStore = signalStore(
{ providedIn: 'root' },
withState({ flights: [] as Flight[] }),
withRedux({
actions: {
public: {
load: payload<{ from: string; to: string }>(),
},
private: {
loaded: payload<{ flights: Flight[] }>(),
},
},
reducer(actions, on) {
on(actions.loaded, ({ flights }, state) => {
for (const flight of flights) { // <-- error: Type never must have an iterator ...
console.log(flight);
}
patchState(state, { flights });
});
},
effects(actions, create) {
return {};
},
})
);
Is there anything i am missing maybe?
Very excited about the library and can't wait to use it in production.
rainerhahnekamp commented
Thanks for reporting. I can confirm it. Expect a fix soon.
rainerhahnekamp commented
Fixed in #15
rainerhahnekamp commented
@giniedp the fix has been integrated into 0.0.7. Please not, that the reducers' on
function got a change as well. The parameters of the function have been changed. First parameter is the state and the second the action.
Thanks for reporting this bug.