“RegistryGroup”类型的参数不能分配给类型参数?

伊琳娜

我使用 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}));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

参数类型“对象?” 不能分配给参数类型“颜色”

类型“ X”的参数不能分配给类型“ Y”的参数

部分类型的参数不能分配给类型的参数

类型“ Response”的参数不能分配给类型“ SetStateAction”的参数

参数类型“RxString”不能分配给参数类型“String”

类型“ X”的参数不能分配给类型“ X”的参数

类型“ Location”的参数不能分配给“ BackgroundGeoLocationEvents”类型的参数

类型“ void”的参数不能分配给类型“ Action”的参数

“Params”类型的参数不能分配给“string”类型的参数

类型参数不能分配给 BaseUI 类型的参数

参数类型“动态”不能分配给参数类型“FirebaseOptions?”

“预订”类型的参数不能分配给“功能”类型的参数

'true' 类型的参数不能分配给类型的参数

类型的参数不能分配给类型的参数

参数类型 'String"?"' 不能分配给参数类型 'String'

'number'类型的参数不能分配给'string'类型的参数

参数类型“TimeOfDay”不能分配给参数类型“DateTime”

WebStorm:参数类型,不能分配给参数类型ObjectConstructor

“ HTMLElement”类型的参数不能分配给“ CanvasImageSource”类型的参数

类型'“”'的参数不能分配给类型'“ prototype”'茉莉的参数

类型'InputType []'的参数不能分配给类型'GenericType []'的参数

类型“事件”的参数不能分配给类型的参数

类型'Element []'的参数不能分配给'元素'类型的参数

参数类型不能分配给参数类型

“1”类型的参数不能分配给“number[]”类型的参数

参数类型“对象?” 不能分配给参数类型“num”

参数类型'Future <>'不能分配给参数类型''

参数类型“对象?” 不能分配给参数类型 List

“any[]”类型的参数不能分配给“string”类型的参数