'RegistryGroup' 类型的参数不能分配给类型的参数?
Argument of type 'RegistryGroup' is not assignable to parameter of type?
我使用 NgRx。
调度操作是:
this.store.dispatch(RegistryActions.ToggleRegistryBlockAction(block));
其中块的类型:
export interface RegistryGroup extends RegistryGeneric {
open: boolean;
}
操作:
export const ToggleRegistryBlockAction = createAction(
"[ToggleRegistryBlockOpen] - Toggle Registry",
props<{ block: RegistryGroup }>()
);
为什么我在行 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.
通过像这样 props<{ block: RegistryGroup }>()
定义操作参数,您希望您将传递 {block: someGroup}
对象,而不仅仅是 someGroup
。要修复它,只需将它包裹在对象括号中
this.store.dispatch(RegistryActions.ToggleRegistryBlockAction({block}));
我使用 NgRx。
调度操作是:
this.store.dispatch(RegistryActions.ToggleRegistryBlockAction(block));
其中块的类型:
export interface RegistryGroup extends RegistryGeneric {
open: boolean;
}
操作:
export const ToggleRegistryBlockAction = createAction(
"[ToggleRegistryBlockOpen] - Toggle Registry",
props<{ block: RegistryGroup }>()
);
为什么我在行 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.
通过像这样 props<{ block: RegistryGroup }>()
定义操作参数,您希望您将传递 {block: someGroup}
对象,而不仅仅是 someGroup
。要修复它,只需将它包裹在对象括号中
this.store.dispatch(RegistryActions.ToggleRegistryBlockAction({block}));