Looking to transition my ngrx actions from createAction to a class-based approach, but encountering an error in the declaration of the action within the associated reducer:
export enum ActionTypes {
LOAD_PRODUCTS_FROM_API = '[Products] Load Products From Api'}
export class LoadProductsFromApi implements Action {
readonly type = ActionTypes.LOAD_PRODUCTS_FROM_API;}
const rootReducer = createReducer(
initialState,
on( //ERROR LoadProductsFromApi ERROR //, (state, action) => (<State>{ products: state.products, filterValue: state.filterValue, isLoading: true })));
ERROR : No overload matches this call. Overload 1 of 11, '(creator1: ActionCreator<string, FunctionWithParametersType<any[], object>>, reducer: OnReducer<State, [ActionCreator<string, FunctionWithParametersType<any[], object>>]>): On<...>', gave the following error. Argument of type 'typeof LoadProductsFromApi' is not assignable to parameter of type 'ActionCreator<string, FunctionWithParametersType<any[], object>>'. Type 'typeof LoadProductsFromApi' is not assignable to type 'FunctionWithParametersType<any[], object>'. Type 'typeof LoadProductsFromApi' provides no match for the signature '(...args: any[]): object'. Overload 2 of 11, '(creator: ActionCreator<string, FunctionWithParametersType<any[], object>>, ...rest: (ActionCreator<string, FunctionWithParametersType<any[], object>> | OnReducer<...>)[]): On<...>', gave the following error. Argument of type 'typeof LoadProductsFromApi' is not assignable to parameter of type 'ActionCreator<string, FunctionWithParametersType<any[], object>>'. Type 'typeof LoadProductsFromApi' is not assignable to type 'FunctionWithParametersType<any[], object>'.
my actions.ts
In other words, I am seeking guidance on how to properly register my action class in the reducer without using a switch statement.