Search code examples
angularreduxngrx

Argument of type 'RegistryGroup' is not assignable to parameter of type?


I use NgRx.

Dispatching action is:

this.store.dispatch(RegistryActions.ToggleRegistryBlockAction(block));

Where block has type:

export interface RegistryGroup extends RegistryGeneric {
  open: boolean;
}

Action:

export const ToggleRegistryBlockAction = createAction(
  "[ToggleRegistryBlockOpen] - Toggle Registry",
  props<{ block: RegistryGroup }>()
);

Why do I get this error on the line this.store.dispatch(RegistryActions.ToggleRegistryBlockAction(block));:

Argument of type 'RegistryGroup' is not assignable to parameter of type '{ block: RegistryGroup; }'.
  Property 'block' is missing in type 'RegistryGroup' but required in type '{ block: RegistryGroup; }'.ts(2345)
registry.actions.ts(47, 11): 'block' is declared here.

Solution

  • by defining action params like this props<{ block: RegistryGroup }>() you expect that you will pass {block: someGroup} object, not just someGroup. to fix it just wrap it in object parenthes

    this.store.dispatch(RegistryActions.ToggleRegistryBlockAction({block}));