javascript - Angular ngrx Prop 中没有重载匹配此调用

标签 javascript angular typescript ngrx

在定义 Action 和使用 Prop 时的 Angular 应用程序中,我在 Prop 上得到“没有重载匹配此调用......”

import { createAction, props } from "@ngrx/store";
export const storeCurrentDashboard = createAction(
  "[effect] store current dashboard in state",
  props<Dashboard>()// here i get the error
);

仪表板类如下
export class Dashboard {
  id: number;
  title: string;
  type: DashboardType; // the problem is this property
  blocks?: any[];
}
export enum DashboardType {
  Private = "Private",
  Shared = "Shared",
...
}

如果我删除作为枚举的“类型”属性,一切都可以。
为什么 Prop 有枚举类型的问题?

编译器错误:
   ERROR in ...: error TS2345: Argument of type '"type property is not allowed in action creators"'
 is not assignable to parameter of type 'FunctionWithParametersType<any[], object>'.

最佳答案

and if i remove "type" property which is an enum every thing is ok. why props have problem with enum types?



type就像 NgRx 的保留字,在 createAction调用,它匹配第一个参数。

关于javascript - Angular ngrx Prop 中没有重载匹配此调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61185269/

相关文章:

angular - 为什么我必须在 NgModule 的导入中使用 AlertModule.forRoot()?

javascript - 在 Document.write() 之后调用函数时遇到问题

javascript - 在使用 CDN 版本的 CKeditor 时尝试加载表情符号插件...CORS 问题

javascript - 获取 JavaScript 对象的所有键

javascript - 在订阅时重复调用 Angular 中的 http

javascript - Angular 错误this.mymethod is not a function

javascript - 穆工具|独特的电子邮件验证

javascript - Angular 4 多级 Accordion 问题

javascript - typescript:带有属性的函数

angular - RxJS startWith在Angular 4应用程序中生成TypeScript编译器错误