在定义 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/