I want to create an Action with an array as an argument, but this doesn't type check:
export const action_organizations_available = createAction(
CoreActionTypes.ORGANIZATIONS_AVAILABLE,
props<Organization[]>()
);
I get props(): "arrays are not allowed in action creators"
.
It works fine when the type is not an array.
Using props<{ organizations: Organization[] }>
works, but I wonder if it's the best practice.
What is the best practice when expecting an array as an argument in an action?
You have to wrap it into an object:
export const action_organizations_available = createAction(
CoreActionTypes.ORGANIZATIONS_AVAILABLE,
props<{ organizations: Organization[] }>()
);
EDIT: it's now a rule "prefer-inline-action-props" in the NgRx ESLint Plugin.